TGraph is Zombie error message

Hi, I’m a beginner at using ROOT and I’m trying to plot a graph using data from a txt file, but for a reason my txt file can’t be opened. This is the error message I get in the root terminal:
root [1] g = new TGraph(“data.txt”)
Error in TGraph::TGraph: Cannot open file: data.txt, TGraph is Zombie
(TGraph *) 0x7faff5900500

data.txt is in the same directory where all my macros are which have worked so far, so the location should be no problem. When I write a macro and include the above line and try to execute it, I get the same message “Cannot open file … TGraph is Zombie” and when I do g->Draw(), I get an empty canvas (which is no surprise if data.txt can’t be opened) and I also get an error message “illegal number of points(0)” (which also makes sense) So I think the problem is with not being able to open data.txt

Any suggestions?


Either give the full path of the file, or put the file in the current directory.

It is in the current directory

You mean both the macro and the data files are in the same (current) directory?

Yes, they are. (Also, I’m not sure how to give the full path in the root terminal)
EDIT I deleted data.txt from that directory, and I got the very same error message when data.txt was still there.

Well, simply like this:

g = new TGraph("/path/where/your/file/is/data.txt")

Thanks a lot, finally I didn’t get the error message using the full path, but now only 1 data point is plotted, (and there are 14 data points.) The range of the x and y axis is too small for the other data points to be seen, and I can’t seem to find a reference for how to change that with TGraph. Have you ever had that issue?

Nope. What is the format of your data (i.e. could you paste a few lines here)?

I attached my data file I’m using. (It’s just made up data for practice)

data.txt (71 Bytes)

Your data has Mac line endings (CR only). Try with this one:data_copy.txt (71 Bytes)
which has correct (Linux/LF) line endings

sed -i -e '{s/\r/\n/g}' data.txt

omg, it works perfectly, thank you! How can I do this conversion?

See the previous @Wile_E_Coyote answer

Do you know what the equivalent is for mac terminal? When I try to use this, I receive the following error:

sed: 1: "{s/\r/\n/g}": bad flag in substitute command: '}'

tr ‘\r’ ‘\n’ < macfile.txt > unixfile.txt

this one works for me

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.