Ascii file to ttree


I want to save ascii file data in to my ttree. However, the problem is that for every ascii file, I have some explanation on the top part of the file. This text makes me hard to bring only the data numbers. My code is as follows

void oscilloscope()
	fstream file;"c1test.txt", ios::in);
	double x, y;
	TFile *output = new TFile("c1test.root", "RECREATE");
	TTree *tree = new TTree("tree", "tree");
	tree->Branch("x", &x, "x/D");
	tree->Branch("y", &y, "y/D");

		file >> x >> y;
		if(file.eof()) break;
		cout << x << " " << y <<endl;

Please read tips for efficient and successful posting and posting code

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

If you know how many lines you have to ignore, you can do a simple for loop (just before your while loop) with a getline to read each entire line (that you want to ignore) at a time.

1 Like

thank you very much for the reply, I will try to go over get line :slightly_smiling_face:

…and a belated welcome to the ROOT forum!

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