Using data files in root


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi!
I may be being dim, but how can I upload data into root to plot/manipulate from a file on my computer ie from excel or origin.
I just can’t see anywhere on the desktop control interface where I can import a file? Can I even do this?

I don’t think ROOT can read data from Excel or any non-text (ASCII) files other than root’s own (.root) files.
A safe bet is to have the input data in CSV files (with comma, space, semicolon, tab, or similar, as column separator), then in ROOT (in the interactive prompt or in a macro) read the files yourself the c++ way (or the python way, if using pyroot) into arrays, vectors, etc. and from there create histograms, graphs, TTrees, etc. (search for examples on “reading ascii files” in this forum; also go to the User’s Guide and check examples in the Documentation link above this forum). You can also directly read a csv file into a graph, for exmaple, but you need to prepare the input file in a specific format, or tell root some things about the file.

1 Like

Thanks! I have then saved in ascii files, my issue is if I try to tell it to read the file, it doesn’t know where it is, unless it is saved in a directory on the desktop. However I don’t know how to put it there.

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