Hi.
I need to read a text file by lines, storing the result in a
cell array of string like the textread function does. The
problem is each line is compound of various strings
separated by whitespaces, and I want to retrieve the whole
content of each line, not as separated strings.
I think it can't be done with textread so I've tried with
textscan. But now the problem is that texscan returns a cel
array and I need a cell array of strings. How could I
convert it to an array of strings?
Thanks a lot.
|
|
0
|
|
|
|
Reply
|
asdf209 (154)
|
5/26/2008 7:04:02 AM |
|
"Dani " <asdf@asdf.com> wrote in message
<g1dnd2$t67$1@fred.mathworks.com>...
> Hi.
> I need to read a text file by lines, storing the result in a
> cell array of string like the textread function does. The
> problem is each line is compound of various strings
> separated by whitespaces, and I want to retrieve the whole
> content of each line, not as separated strings.
> I think it can't be done with textread so I've tried with
> textscan. But now the problem is that texscan returns a cel
> array and I need a cell array of strings. How could I
> convert it to an array of strings?
> Thanks a lot.
Use the proper delimiter:
S = textread('file.txt','%s','delimiter','\n')
hth
Jos
|
|
0
|
|
|
|
Reply
|
DELjos (627)
|
5/26/2008 7:12:01 AM
|
|
"Jos " <DELjos@jasenDEL.nl> wrote in message
<g1dns1$32u$1@fred.mathworks.com>...
> "Dani " <asdf@asdf.com> wrote in message
> <g1dnd2$t67$1@fred.mathworks.com>...
> > Hi.
> > I need to read a text file by lines, storing the result in a
> > cell array of string like the textread function does. The
> > problem is each line is compound of various strings
> > separated by whitespaces, and I want to retrieve the whole
> > content of each line, not as separated strings.
> > I think it can't be done with textread so I've tried with
> > textscan. But now the problem is that texscan returns a cel
> > array and I need a cell array of strings. How could I
> > convert it to an array of strings?
> > Thanks a lot.
>
> Use the proper delimiter:
>
> S = textread('file.txt','%s','delimiter','\n')
>
> hth
> Jos
>
Thank you.
I thought textread only accepted filename and format parameters.
|
|
0
|
|
|
|
Reply
|
asdf209 (154)
|
5/26/2008 8:47:02 AM
|
|
|
2 Replies
65 Views
(page loaded in 0.032 seconds)
Similiar Articles: textscan error: out of memory - comp.soft-sys.matlabI am trying to use textscan to read data from a huge text file. Below is the code: A = textscan(fid, '%f', 'delimiter', ' ', 'headerlines', 6); % ... reading complex text files into Matlab - comp.soft-sys.matlab ...Help reading in TMY3 (.csv files) data into Matlab - comp.soft-sys ... Look at using ... textscan - Read formatted data from text file or string Note Before reading a file ... Using textscan to read a csv file - comp.soft-sys.matlab ...textscan - Read formatted data from text file or string Note Before reading a file with textscan, you must open the file with the ... Using a text editor, create a file ... textscan reads only the first data line - comp.soft-sys.matlab ...reading the previous line in a text file - comp.soft-sys.matlab ... textscan reads only the first data line - comp.soft-sys.matlab ... Reading a Line from a file - comp ... reading the previous line in a text file - comp.soft-sys.matlab ...Reading a Line from a file - comp.soft-sys.matlab I'm trying to read a .txt file with ... or string C = textscan(fid, 'format') reads data from an open text file ... Read ... Strread String and floating point number problem! - comp.soft-sys ...Hi, I am trying to use strread, to read two columns of data in a text file. ... Thanks, > > > > Robbie > > Then, first > > help textscan ... Reading ASCII text file with variable number of columns - comp ...... have an all-string, tab-delimited ASCII text file of ... textread (older versions, deprecated) or textscan ... Reading ASCII text file with variable number of columns - comp ... read file with variable column numbers - comp.soft-sys.matlab ...I try textscan and importdata, which seems need same columns in each rows. ... Reading ASCII text file with variable number of columns - comp ... read file with variable ... help reading csv file with string - comp.soft-sys.matlab ...Reading a big .CSV file into SAS - comp.soft-sys.sas help reading csv file with string - comp.soft-sys.matlab ... Hi, I'm using textscan to read a very large csv file ... Reading a Header txt file - comp.soft-sys.matlab... then fseek() back to the remembered position, then textscan(fid, repmat ... Reading ASCII text file with variable number of columns - comp ..... how it was originally ... textscan - Read formatted data from text file or stringC = textscan(fid, 'format') reads data from an open text file identified by the file identifier fid into cell array C. The format input is a string of conversion ... MATLAB - Reading Arbitrary Format Text Files with TEXTSCAN DemoAll the information is read into cell arrays, allowing the storage of different size blocks. Open the Text File for Reading fid = fopen('test80211.txt', 'r'); % Open ... 7/8/2012 1:01:19 PM
|