Thread Subject: Importing text files with multiple headers

Subject: Importing text files with multiple headers

From: Leo Steenson

Date: 2 Jul, 2009 14:06:02

Message: 1 of 2

I am trying to import text files into matlab. The problem is that within the files there is a text header then some numerical data then header, data, header etc.

When I try to import the file (specifying that the numerical data starts on line 3) Matlab imports the first set of numerical data up until the next alphabetical line but not the whole file.

I have until now just repetively specified a larger and larger header (in a loop) as all the numerical data are of equal numbers of lines, but this is not nice and I miss some data for longer files.

Does anyone know of a command to ignore all lines of text and only import the data, specifically when the data is interupted through the file with words.

Thanks

Subject: Importing text files with multiple headers

From: dpb

Date: 2 Jul, 2009 23:46:34

Message: 2 of 2

Leo Steenson wrote:
> I am trying to import text files into matlab. The problem is that
> within the files there is a text header then some numerical data then
> header, data, header etc.
...
> Does anyone know of a command to ignore all lines of text and only
> import the data, specifically when the data is interupted through the
> file with words.
...
Not a prebuilt function, no--you can do the same thing as you're
presently doing except at a lower level w/ fgetl(), fread(), sscanf(),
strread() and friends to handle your file structure, however.

Whether there's a more general version of textread() et al. at the file
exchange that could help might be worth a look-see...

--

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
import Leo Steenson 2 Jul, 2009 10:09:03
headers Leo Steenson 2 Jul, 2009 10:09:03
text and numbers Leo Steenson 2 Jul, 2009 10:09:03
read file Leo Steenson 2 Jul, 2009 10:09:03
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com