I'm using numpy.genfromtxt to import a data column from a csv file as a variable twice (each column corresponding to different variables x and y). I'm getting a Value Error: (got 3 columns instead of 1) even though I;m specifying which column to use. The code is as follows:
import numpy as np
file = 'E:/TPA/AOM_8.csv'
file = os.path.normpath(file)
x = np.genfromtxt(file, delimiter=',', usecols=1, skip_header=9)
print(x)
y = np.genfromtxt(file, delimiter=',', usecols=3, skip_header=9)
print(y)
The weird thing is the code has no problem printing 'x' but it does with 'y'. If I change 'y' to
y = np.genfromtxt(file, delimiter=',', usecols=2, skip_header=9)
then it works.
A sample of the file is below:
ASCII data file created with TiePie Multi Channel software. www.tiepie.com.
2021-08-27 18:25:57 437m
Sample number,Relative time,Data collector1,Data collector2
,s,V,V
0,0,4.0176473,6.1250002
1,1E-5,4.0078434,6.0784316
2,2E-5,4.001961,6.1274512
3,3E-5,4.029412,6.0980394
4,4E-5,4.0333336,6.1274512
5,5E-5,4.0009806,6.1446081
6,6E-5,4.0205885,6.1274512
7,7E-5,4.0098042,6.1299022
8,8E-5,4.0058826,6.1078434
9,9E-5,4.0098042,6.154412
10,0.0001,4.0225493,6.1053924
11,0.00011,4.0323532,6.0588237
12,0.00012,4.0147061,6.1421571