I have character delimited files which have different sets in the file
File
@Set 1
0,1,2,3
2,3,4,5
.
.
@Set 2
3,4,5,6
4,5,6,7
.
.
I want to make arrays with data from each set and I will also need from which set the data is taken. I am using
with open('File', 'r') as f:
data = {}
numbers = []
for line in f:
ln = line.strip()
if '@Set' in ln:
data[ln] = numbers
numbers = []
elif ln:
numbers.append([float(n) for n in ln.split(',')])
I can see data['@Set 1']
but I am not able to use specific columns, and I want to use numpy.genfromtxt
because I will need arrays where I can access columns.