Thread Subject: Reading Text files

Subject: Reading Text files

From: Sahray Gambaro

Date: 19 Nov, 2009 20:49:03

Message: 1 of 4

I have inputs files that contains numbers and words. I want to archive in a vector or a struct each of the numbers that I have in that file. The problem is the load function does not work for that and when I try to use fopen and the other functions to read the file I can not manipulate the data in the file.

Example of the input file:
 1234 ABC 5678 9012
1234 5678 9012 3456 7890
/* Input File options...... */
/* ****************** */
1234 5678 9012 3456 7890
....
...
etc.

Any suggestions?

--Sahray

Subject: Reading Text files

From: dpb

Date: 19 Nov, 2009 20:52:52

Message: 2 of 4

Sahray Gambaro wrote:
> I have inputs files that contains numbers and words. I want to
> archive in a vector or a struct each of the numbers that I have in
> that file.
> The problem is the load function does not work for that and when I try
> to use fopen and the other functions to read the file I can not
> manipulate the data in the file.
>
> Example of the input file:
> 1234 ABC 5678 9012
> 1234 5678 9012 3456 7890
> /* Input File options...... */
> /* ****************** */
> 1234 5678 9012 3456 7890
> ....
> ...
> etc.
>
> Any suggestions?

Are the values in the lines preceding the comment lines significant?

Are the locations of text and numeric values consistent within each line
and are lines containing text and numeric values the same?

--

Subject: Reading Text files

From: Sahray Gambaro

Date: 19 Nov, 2009 21:43:18

Message: 3 of 4

dpb <none@non.net> wrote in message <he4b7d$53c$2@news.eternal-september.org>...
> Sahray Gambaro wrote:
> > I have inputs files that contains numbers and words. I want to
> > archive in a vector or a struct each of the numbers that I have in
> > that file.
> > The problem is the load function does not work for that and when I try
> > to use fopen and the other functions to read the file I can not
> > manipulate the data in the file.
> >
> > Example of the input file:
> > 1234 ABC 5678 9012
> > 1234 5678 9012 3456 7890
> > /* Input File options...... */
> > /* ****************** */
> > 1234 5678 9012 3456 7890
> > ....
> > ...
> > etc.
> >
> > Any suggestions?
>
> Are the values in the lines preceding the comment lines significant?
>
> Are the locations of text and numeric values consistent within each line
> and are lines containing text and numeric values the same?
>
> --

all the numeric values are significant and the location of the tex and the quantity of how many numeric values you will find in the text file are not consistent.

Each value represent something different and important, so I cant ignore it and each bunch of values could have different amounts.

Is this make more clear my problem?

Thanks,

Subject: Reading Text files

From: dpb

Date: 19 Nov, 2009 22:07:14

Message: 4 of 4

Sahray Gambaro wrote:
...

> all the numeric values are significant and the location of the tex
> and
the quantity of how many numeric values you will find in the text file
are not consistent.
>
> Each value represent something different and important, so I cant
ignore it and each bunch of values could have different amounts.
>
> Is this make more clear my problem?

Then you'll have to read each line and parse each field
individually--unless there's a pattern to exploit textread() and friends
are of little help.

help fgetl

and

lookfor token

are good starting points, probably.

--

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com