I’m working on a fit program for SIP data right now. Unfortunately the data comes within a csv table with the following structure :
f; Abs(Zm); Std(Abs); Phi(Zm); Std(Phi); Re(Zm); Im(Zm); Time [s]
1.0000000e-001; 7712.6262; 0.0247; -0.003774; 0.000001; 7712.5713; -29.1074; 3418623040
2.0000000e-001; 7712.4351; 0.0030; -0.007543; 0.000001; 7712.2157; -58.1732; 3418623056
5.0000000e-001; 7710.8455; 0.0094; -0.018837; 0.000002; 7709.4775; -145.2434; 3418623063
1.0000000e+000; 7705.3763; 0.0098; -0.037637; 0.000000; 7699.9195; -289.9395; 3418623067
2.0000000e+000; 7683.8120; 0.0241; -0.075058; 0.000001; 7662.1778; -576.1935; 3418623069
5.0000000e+000; 7539.7945; 0.0080; -0.184724; 0.000002; 7411.5201; -1384.8720; 3418623071
1.0000000e+001; 7088.6894; 0.0060; -0.351521; 0.000001; 6655.2169; -2440.8206; 3418623072
f; Abs(Z12); Phi(Z12); Abs(Z34); Phi(Z34); Abs(Z14); Phi(Z14); Time [s]
1.0000000e-001; 1.7821; 3.139014; 0.2545; -3.141592; 7710.5896; -0.003774; 3418623040
2.0000000e-001; 1.7850; 3.133381; 0.2572; -3.126220; 7710.3930; -0.007543; 3418623056
5.0000000e-001; 1.7755; 3.121223; 0.2514; -3.133763; 7708.8186; -0.018838; 3418623063
1.0000000e+000; 1.7683; 3.100815; 0.2503; 3.139466; 7703.3580; -0.037638; 3418623067
2.0000000e+000; 1.8091; 3.058834; 0.2538; -3.123705; 7681.7502; -0.075060; 3418623069
5.0000000e+000; 1.5547; 2.943611; 0.2398; -3.136317; 7538.0045; -0.184727; 3418623071
I’m using a numpy.loadtxt() routine to collect the data from the table like this :
def load_datafile(filename):
try:
x_data, y_data = numpy.loadtxt(filename , unpack=True, usecols=(0,1),)
except IOError:
print('There was an error opening the file: {0}'.format(filename))
x_data=[]
y_data=[]
return x_data, y_data
I know there is no further identifier for using a specific block from a table in the loadtxt() command. But is there a handy workaround?
Otherwise is there a simple script which can do the rearranging of the csv-input file to single block colums?
Thanks in advance!
Greets,
Gunnar
You could first split the input data into blocks, then use loadtxt or genfromtxt (I prefer this one, because it has an option to read headers).