How to create a graph with single column txt file?

Hi,

I am a very new user of Root and I have been stuck on importing data from a single column txt file for a long time. I am trying to use TGraph and the code goes:

TGraph my_graph(“filename”,"%lg %lg")
my_graph->Draw(“CA”)

Because my original txt file contains only one column of data, I used excel to added another column of index (time) and saved it as txt. However, I could not read one point from the txt file using the code above.

If I add the extra column of time manually, the code works alright. I assume excel somehow messed up the format but I don’t know how I could import the data. Thank you for any help!

Check that your column delimiters are spaces or tabs. If they are anything else, you can use the Option argument to specify a delimiter:

http://root.cern.ch/root/html/TGraph.html#TGraph:TGraph@10

Jean-François