From: dpb on 7 Jul 2010 16:00 Brought to light in another thread of poster w/ fixed width fields but no delimiter wherein import wizard, etc, failed to parse the empty fields. Thought should be able to use the width but no; at least w/ my early version and as I read doc on current textscan() probably won't work there, either. So, is the following a) broke in early release but fixed now, or b) wad? >> s = ' 3 12.5'; >> [x,y,z]=strread(s,'%3d%3d%3.1f',1) x = 3 y = 12 z = 0.5000 >> OTOH, >> [x,y,z]=strread(strrep(s,' ','0'),'%3d%3d%3.1f') x = 3 y = 1 z = 2.5000 as expected/desired. So, is there any way to parse the "empty" fields that aren't really empty w/o resorting to somesuch workaround as the above? And, b) what is actually going on w/ the prior result--it makes no sense to me to get y=12 z=0.5, certainly. --
From: Oleg Komarov on 7 Jul 2010 16:24 dpb <none(a)non.net> wrote in message <i12mii$vth$1(a)news.eternal-september.org>... > Brought to light in another thread of poster w/ fixed width fields but > no delimiter wherein import wizard, etc, failed to parse the empty fields. > > Thought should be able to use the width but no; at least w/ my early > version and as I read doc on current textscan() probably won't work > there, either. > > So, is the following > > a) broke in early release but fixed now, or > > b) wad? > > >> s = ' 3 12.5'; > >> [x,y,z]=strread(s,'%3d%3d%3.1f',1) > x = > 3 > y = > 12 > z = > 0.5000 > >> > > OTOH, > > >> [x,y,z]=strread(strrep(s,' ','0'),'%3d%3d%3.1f') > x = > 3 > y = > 1 > z = > 2.5000 > > as expected/desired. > > So, is there any way to parse the "empty" fields that aren't really > empty w/o resorting to somesuch workaround as the above? > > And, b) what is actually going on w/ the prior result--it makes no sense > to me to get y=12 z=0.5, certainly. > > -- I found this problem several times and apparently there is no way to parse empty fields (also confirmed by tech support) !!! I thought it was just my problem but since you bring it to our attention I can confirm that my solution was similar, resorting to replace and textscanning after. Oleg
From: dpb on 7 Jul 2010 16:49 Oleg Komarov wrote: .... > I found this problem several times and apparently there is no way to > parse empty fields (also confirmed by tech support) !!! I thought it was > just my problem but since you bring it to our attention I can confirm > that my solution was similar, resorting to replace and textscanning after. .... Oleg, out of curiosity do you happen to know if the behavior mimics C scanf() formatting string behavior or is it unique to Matlab? I don't know C well enough to have a clue (and am not sure there's a working-at-the-moment C compiler handy to give a short test)... --
From: Oleg Komarov on 7 Jul 2010 16:56 > I found this problem several times and apparently there is no way to parse empty fields (also confirmed by tech support) !!! I thought it was just my problem but since you bring it to our attention I can confirm that my solution was similar, resorting to replace and textscanning after. > > Oleg I had a test.txt file: 0000000001901011943 IBO009900002002010142700EUR000000000166322000000000000000 0000000001901011943USABO009900002002010142700EUR000000000166422000000000000000 And the solution proposed by the support (commented in italian): %% Apertura del file fid = fopen('leggi.txt','r'); %% Lettura stringhe di riga A = textscan(fid,'%s','delimiter','\n'); A = cell2mat(A{1}); %% Salvataggio stringhe field1 = A(:,1:19); field2 = A(:,20:22); %% Chiusura del file fclose(fid) Oleg
From: Oleg Komarov on 7 Jul 2010 16:58 dpb <none(a)non.net> wrote in message <i12pe1$nkv$1(a)news.eternal-september.org>... > Oleg Komarov wrote: > ... > > > I found this problem several times and apparently there is no way to > > parse empty fields (also confirmed by tech support) !!! I thought it was > > just my problem but since you bring it to our attention I can confirm > > that my solution was similar, resorting to replace and textscanning after. > ... > > Oleg, out of curiosity do you happen to know if the behavior mimics C > scanf() formatting string behavior or is it unique to Matlab? I don't > know C well enough to have a clue (and am not sure there's a > working-at-the-moment C compiler handy to give a short test)... > > -- Not fluent in C...sorry. Oleg
|
Next
|
Last
Pages: 1 2 Prev: Creating a logical mask from a 3D convex hull Next: About behavior of KeyPressFcn |