Prev: Legend
Next: can you omit "handles." prefix?
From: Dan on 28 Apr 2010 12:59 Hello, I have a data file like this: O 7535.74430 15619.34840-12829.17868 0.66112 1.36827 -1.13013 C 7535.34343 15618.55857-12828.41117 0.46098 0.95723 -0.78018 H -11902.43043 -8591.00480 8684.13318 -0.06393 -0.04638 0.04660 H 114.03246 -9406.94919 6751.53665 0.00059 -0.05045 0.03623 Where the 3rd and 4th column meet the space is used up by the input there so when I try to import I get a distorted matrix. Is there any way to use the import wizard and not specify a delimiter but a column number instead? This file is output from a Fortran program I don’t have access to.
From: Walter Roberson on 28 Apr 2010 15:59 Dan wrote: > Hello, I have a data file like this: > > O 7535.74430 15619.34840-12829.17868 0.66112 1.36827 -1.13013 > C 7535.34343 15618.55857-12828.41117 0.46098 0.95723 -0.78018 > H -11902.43043 -8591.00480 8684.13318 -0.06393 -0.04638 0.04660 > H 114.03246 -9406.94919 6751.53665 0.00059 -0.05045 0.03623 > > Where the 3rd and 4th column meet the space is used up by the input > there so when I try to import I get a distorted matrix. Is there any > way to use the import wizard and not specify a delimiter but a column > number instead? This file is output from a Fortran program I > don’t have access to. I wouldn't bother with the import wizard. fid = fopen('TheFileName'); inputs = textscan(fid, '%c %12f%12f%12f %f %f %f'); fclose(fid); You may wish to add the 'CollectOutputs', 1 parameter pair to the end of the textscan call.
From: dpb on 28 Apr 2010 16:11 Walter Roberson wrote: .... > I wouldn't bother with the import wizard. > > fid = fopen('TheFileName'); > inputs = textscan(fid, '%c %12f%12f%12f %f %f %f'); > fclose(fid); > > You may wish to add the 'CollectOutputs', 1 > parameter pair to the end of the textscan call. Walter beat me to it but note all the floats are E12.5 so a string of ['%c repmat('%12f',1,6)] is a little more concise. That scientific/engineering/computational was never considered in C was never more demonstrated by the lack of a decent formatting string facility including repeat counts, etc., etc., ... :( One wonders that TMW hasn't figured out some extensions for the field given the number of questions and the painfulness of writing same. The above could be 'A2,6E12.5' in Fortran for example--easy, neat, legible in writing and reading. The use of the letter to indicate the field type trailing the numeric values makes repeat counts problematical in parsing C format strings was a major foo-pah imo... --
From: TideMan on 28 Apr 2010 16:35 On Apr 29, 8:11 am, dpb <n...(a)non.net> wrote: > Walter Roberson wrote: > > ... > > > I wouldn't bother with the import wizard. > > > fid = fopen('TheFileName'); > > inputs = textscan(fid, '%c %12f%12f%12f %f %f %f'); > > fclose(fid); > > > You may wish to add the 'CollectOutputs', 1 > > parameter pair to the end of the textscan call. > > Walter beat me to it but note all the floats are E12.5 so a string of > ['%c repmat('%12f',1,6)] is a little more concise. > > That scientific/engineering/computational was never considered in C was > never more demonstrated by the lack of a decent formatting string > facility including repeat counts, etc., etc., ... :( > > One wonders that TMW hasn't figured out some extensions for the field > given the number of questions and the painfulness of writing same. The > above could be 'A2,6E12.5' in Fortran for example--easy, neat, legible > in writing and reading. The use of the letter to indicate the field > type trailing the numeric values makes repeat counts problematical in > parsing C format strings was a major foo-pah imo... > > -- I agree entirely, dbp Coming from Fortran to Matlab, this was a major transition. But one learns with time............. Nevertheless, I still find Fortran a better tool to read from complicated text files. And it's much faster reading in line-by-line from large files.
From: Dan on 28 Apr 2010 19:53
TideMan <mulgor(a)gmail.com> wrote in message <f4f4235c-4887-4823-b6bc-837d7edc7f9b(a)g39g2000pri.googlegroups.com>... > On Apr 29, 8:11 am, dpb <n...(a)non.net> wrote: > > Walter Roberson wrote: > > > > ... > > > > > I wouldn't bother with the import wizard. > > > > > fid = fopen('TheFileName'); > > > inputs = textscan(fid, '%c %12f%12f%12f %f %f %f'); > > > fclose(fid); > > > > > You may wish to add the 'CollectOutputs', 1 > > > parameter pair to the end of the textscan call. > > > > Walter beat me to it but note all the floats are E12.5 so a string of > > ['%c repmat('%12f',1,6)] is a little more concise. > > > > That scientific/engineering/computational was never considered in C was > > never more demonstrated by the lack of a decent formatting string > > facility including repeat counts, etc., etc., ... :( > > > > One wonders that TMW hasn't figured out some extensions for the field > > given the number of questions and the painfulness of writing same. The > > above could be 'A2,6E12.5' in Fortran for example--easy, neat, legible > > in writing and reading. The use of the letter to indicate the field > > type trailing the numeric values makes repeat counts problematical in > > parsing C format strings was a major foo-pah imo... > > > > -- > > I agree entirely, dbp > Coming from Fortran to Matlab, this was a major transition. > But one learns with time............. > > Nevertheless, I still find Fortran a better tool to read from > complicated text files. > And it's much faster reading in line-by-line from large files. Thank you all! This will help a lot. |