Select columns

Hi Rooters!!

I have a problem with a TGraphAsymmErrors…
the format to give in input the data in this graph is TGraphAsymmErrors( x,y,elx, ehx, ely, ehy)
My problem is that I have to read a data from an ASCII file, so I select the columns with %*s… the problem is that my elx is a column befor respect to y…

so if I would have only x y I do:

TGraphAsymmErrors( “data.csv”,"%*s %*s %*s %*s %*s %*s %lg %*s %*s %*s %*s %*s %lg" )

so my is 7 column and y is 13, but my elx is 10 and if I sign the 10 column with %lg, this value is took like a y and not like elx…

How can I do?

thanks a lot!!! =)

1 Like

Hi,

isn’t it much easier to first format the columns of your original file with data in the exact needed order? For example, if your x, y and elx occupy columns #7, 13 and 10, respectively, and, let’s say, ehx, ely and ehy are in columns #15, 4 and 11 (I chose these numbers randomly), you can do the following:

awk 'BEGIN {OFS = " "}; {print $7,$13,$10,$15,$4,$11}' data.csv > data_modified.csv

, and the newly created data_modified.csv will have your columns rearranged in the order 7-13-10-15-4-11, and all other columns will be deleted. Then you simply do

TGraphAsymmErrors("data_modified.csv","%lg %lg %lg %lg %lg %lg" )

yes, maybe is not the best way but is the easier, format the file with the columns in order.

Thanks!! =)