Convert txt file to root

Dear all,
Iam trying convert my txt file to Root by using this macro but when I run it in terminal, I get the following error messages (Limitation: fscanf only takes upto 12 arguments ascii2root.C:18:) and I do not know what is wrong? :cry: :cry: :frowning:
my macro and txt file in attachment
Thanks

Larin
ha.txt (148 KB)
ascii2root.C (1.37 KB)

Hi,

the problem is stated in the error message: The implementation of fscanf in ROOT only takes a maximum of 12 arguments. Solutions could be to use compiled code and your system’s fscanf, or to parse the input file with C++ streams.

If you can live with getting rid of the first 2 lines in your data file (they don’t contain data) you could also use the integrated text file reader in TTree (and so also in TNtuple).

{
  TNtuple data("data", "", "a1:a2:a3:a4:a5:a6:a7:a8:a9:a10:a11:a12:a13:a14:a15:a16");
  data.ReadFile("ha.txt");
}