How to read a .dat file with column headings and intermittent NAs

I have a .dat files that were generated with R so they have column headings and the missing values are replaced with “NA”. Is there a way to read these files to a ttree? Thanks in anticipation to your help.


try this function:

Or see this section in the User’s guide:

Thanks StephanH for the links. I have seen both documents before posting the question. The ReadFile breaks when I declare either of the columns as a double/float because of the header row and the NAs in the vector.

I was able to solve this by looping over rows of the vector (as a string) in each of the .dat files using the “getLine” command. This way I was able to test for NAs and reject them. I then ran “atof” on the string before filing them in the tree.

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