From: LindsE on 4 Feb 2007 10:40 Good day, everyone! I am having some trouble writing a command with textscan to read-in the data I am using for my research. The .dmb file has 9 columns of data that I wish to access, though not every line will be needed (lines starting with character S are to be skipped). I can read in the first 5 fields of the first line of data, but the 6th through 9th fields are not cooperating (the 6th entry in the cell is just a double quote, ". Nothing appears after this field) The following is the first row of data I wish to read-in: G 1387 2228 2001-03-25 14:15:00 44.176 296.334 401650000 G Here is the code I'm trying, unsuccessfully: fid=fopen('C:path\data.dmb','r'); [A,position]=textscan(fid, '%1c %4f %4f %10s %8s, %6f, %7f, %9f, %1c,','multipleDelimsAsOne',1,... 'delimiter','','commentStyle','S'); fclose(fid) If anyone has ANY suggestions as to what may be going wrong here, I would really appreciate them. I am new using this command, and haven't had much luck hacking through it myself. Thanks so much; Lindsay
From: Pieter Schevenels on 4 Feb 2007 10:58 LindsE wrote: > Good day, everyone! > > I am having some trouble writing a command with textscan to read-in > the data I am using for my research. > The .dmb file has 9 columns of data that I wish to access, though not > every line will be needed (lines starting with character S are to be > skipped). I can read in the first 5 fields of the first line of data, > but the 6th through 9th fields are not cooperating (the 6th entry in > the cell is just a double quote, ". Nothing appears after this field) > > The following is the first row of data I wish to read-in: > > G 1387 2228 2001-03-25 14:15:00 44.176 296.334 401650000 > G > > Here is the code I'm trying, unsuccessfully: > > fid=fopen('C:path\data.dmb','r'); > [A,position]=textscan(fid, '%1c %4f %4f %10s %8s, %6f, %7f, %9f, > %1c,','multipleDelimsAsOne',1,... > 'delimiter','','commentStyle','S'); > fclose(fid) > > > If anyone has ANY suggestions as to what may be going wrong here, I > would really appreciate them. I am new using this command, and > haven't had much luck hacking through it myself. > > Thanks so much; > Lindsay I don't like those comma's from the sixth field on. Maybe it is due to that? Also, 44.176 would be better scanned with the flag %2.3f (the point indicates the comma). Same for 293.334. Does this help? Pieter
From: LindsE on 4 Feb 2007 11:27 On Feb 4, 12:58 pm, "Pieter Schevenels" <pieter.schevenels.stud...(a)kuleuven.be> wrote: > LindsE wrote: > > Good day, everyone! > > > I am having some trouble writing a command with textscan to read-in > > the data I am using for my research. > > The .dmb file has 9 columns of data that I wish to access, though not > > every line will be needed (lines starting with character S are to be > > skipped). I can read in the first 5 fields of the first line of data, > > but the 6th through 9th fields are not cooperating (the 6th entry in > > the cell is just a double quote, ". Nothing appears after this field) > > > The following is the first row of data I wish to read-in: > > > G 1387 2228 2001-03-25 14:15:00 44.176 296.334 401650000 > > G > > > Here is the code I'm trying, unsuccessfully: > > > fid=fopen('C:path\data.dmb','r'); > > [A,position]=textscan(fid, '%1c %4f %4f %10s %8s, %6f, %7f, %9f, > > %1c,','multipleDelimsAsOne',1,... > > 'delimiter','','commentStyle','S'); > > fclose(fid) > > > If anyone has ANY suggestions as to what may be going wrong here, I > > would really appreciate them. I am new using this command, and > > haven't had much luck hacking through it myself. > > > Thanks so much; > > Lindsay > > I don't like those comma's from the sixth field on. Maybe it is due to > that? > Also, 44.176 would be better scanned with the flag %2.3f (the point > indicates the comma). > Same for 293.334. > > Does this help? > > Pieter Pieter: You're a lifesaver!!! I didn't even pick up on the commas, I had been staring at it so long. I thank you more than you can imagine. That worked perfectly. All the best; Lindsay
From: LindsE on 5 Feb 2007 07:58 On Feb 4, 1:27 pm, "LindsE" <LindsEHill...(a)gmail.com> wrote: > On Feb 4, 12:58 pm, "Pieter Schevenels" > > > > <pieter.schevenels.stud...(a)kuleuven.be> wrote: > > LindsE wrote: > > > Good day, everyone! > > > > I am having some trouble writing a command with textscan to read-in > > > the data I am using for my research. > > > The .dmb file has 9 columns of data that I wish to access, though not > > > every line will be needed (lines starting with character S are to be > > > skipped). I can read in the first 5 fields of the first line of data, > > > but the 6th through 9th fields are not cooperating (the 6th entry in > > > the cell is just a double quote, ". Nothing appears after this field) > > > > The following is the first row of data I wish to read-in: > > > > G 1387 2228 2001-03-25 14:15:00 44.176 296.334 401650000 > > > G > > > > Here is the code I'm trying, unsuccessfully: > > > > fid=fopen('C:path\data.dmb','r'); > > > [A,position]=textscan(fid, '%1c %4f %4f %10s %8s, %6f, %7f, %9f, > > > %1c,','multipleDelimsAsOne',1,... > > > 'delimiter','','commentStyle','S'); > > > fclose(fid) > > > > If anyone has ANY suggestions as to what may be going wrong here, I > > > would really appreciate them. I am new using this command, and > > > haven't had much luck hacking through it myself. > > > > Thanks so much; > > > Lindsay > > > I don't like those comma's from the sixth field on. Maybe it is due to > > that? > > Also, 44.176 would be better scanned with the flag %2.3f (the point > > indicates the comma). > > Same for 293.334. > > > Does this help? > > > Pieter > > Pieter: > > You're a lifesaver!!! I didn't even pick up on the commas, I had been > staring at it so long. I thank you more than you can imagine. That > worked perfectly. > > All the best; > Lindsay Hi again all; Also wondering if anyone knows how to use multiple entries for 'commentstyle'? I need to skip rows of data starting with both s and S. Any suggestions? Thanks; Lindsay
|
Pages: 1 Prev: mvncdf in MATLAB 7.3.0(R2006b) Next: Size of index expression is not statically kno |