I have a text file containing simulation data (60 columns, 100k rows):
a b c
1 11 111
2 22 222
3 33 333
4 44 444
... where in the first row are variable names, and beneath (in columns) is the corresponding data (float type).
I need to use all these variables with their data in Python for further calculations. For example, when I insert:
print(b)
I need to receive the values from the second column.
I know how to import data:
data=np.genfromtxt("1.txt", unpack=True, skiprows = 1)
Assign variables "manually":
a,b,c=np.genfromtxt("1.txt", unpack=True, skiprows = 1)
But I'm having trouble with getting variable names:
reader = csv.reader(open("1.txt", "rt"))
for row in reader:
list.append(row)
variables=(list[0])
How can I change this code to get all variable names from the first row and assign them to the imported arrays ?