Re: [ROOT] Reading file

From: Frankland John (frankland@ganil.fr)
Date: Thu Jun 26 2003 - 00:23:45 MEST


Hi David
You don't have to use the ROOT-defined types, but it can help - they 
(try to)
ensure the portability of your code/scripts etc. between different machines,
architectures, OS's, etc.
See http://root.cern.ch/root/Conventions.html
John

david.hou@utoronto.ca wrote:

>i thought for ROOT int must be coded as Int_t, and same fore float, etc.? i may
>be wrong in this aspect here
>
>david
>
>
>
>Quoting Livia FERRO <Livia.Ferro@cern.ch>:
>
>  
>
>>Hello,
>>
>>I'm a Summer Student and I've a problem with root.
>>I would like to read a data file like this:
>>
>>25 ext probe 1 21.93 1052989373314
>>26 ext probe 1 19.95 1052989373362
>>27 ext probe 1 20.25 1052989373418
>>28 ext probe 1 20.40 1052989373465
>>29 ext probe 1 20.36 1052989373517
>>30 ext probe 1 19.99 1052989373620
>>31 ext probe 1 21.17 1052989373683
>>
>>In order to do this, I have written a script:
>>
>>{
>>  gROOT->Reset();
>>
>>  int id;
>>  char name1[10];
>>  char name2[10];
>>  int type;
>>  float measure;
>>  int timestamp;
>>  char temp[200];
>>  FILE *apre;
>>
>>  apre = fopen("extprobe.dat","r");
>>
>>  while(fgets(temp, sizeof(temp), apre) !=NULL) {
>>
>>    sscanf(temp, "%d %s %s %d %g %d",
>>    &id, &name1,&name2,  &type, &measure, &timestamp);
>>    printf("%d %s %s %d %g %d\n",
>>    id, name1,name2, type, measure, timestamp);
>>
>>  }
>>
>>    fclose(apre);
>>}
>>
>>
>>Alas, it doesn't work, because it can't manage to read the last number
>>of each line (it's too long).
>>Could you give any hint?
>>
>>Thank you very much.
>>
>>Livia Ferro
>>
>>
>>    
>>
>
>
>  
>


-- 
John D. Frankland
Beam Coordinator
GANIL
B.P. 55027
14076 CAEN Cedex 05

tel: +33 (0)231454628
fax: +33 (0)231454665



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET