Here's an example of how to construct an array using a delimited text file:
open()
function:file = open("data.txt", "r")
contents = file.read()
For example, if the text file is a CSV file with commas as the delimiter, you can use the split()
method:
data = contents.split(",")
numbers = [int(n) for n in data]
file.close()
Now you should have an array (or list, depending on the programming language) containing the data from the delimited text file.
Asked: 2022-10-10 11:00:00 +0000
Seen: 11 times
Last updated: Mar 12 '22