Thread Subject:
Select data form text

Subject: Select data form text

From: Paul

Date: 24 Jun, 2009 14:27:01

Message: 1 of 3

Hi,

I have the following problem: I want to get values from a text file which looks as followed:
CORRECTIONS=AIR_DENSITY_CORR;
BEGIN_DATA
-130.00 602.89E-03
-120.00 605.77E-03
-110.00 613.07E-03
-100.00 623.12E-03
-90.00 619.39E-03
-80.00 624.38E-03
-70.00 627.40E-03
-60.00 628.70E-03
-50.00 630.17E-03
-40.00 630.05E-03
-30.00 629.16E-03
-20.00 627.44E-03
-10.00 633.75E-03
0.00 627.81E-03
10.00 627.06E-03
20.00 628.62E-03
30.00 630.12E-03
40.00 625.19E-03
50.00 624.92E-03
60.00 626.39E-03
70.00 622.22E-03
80.00 619.85E-03
90.00 617.34E-03
100.00 611.50E-03
110.00 604.46E-03
120.00 599.90E-03
130.00 583.04E-03
END_DATA
END_SCAN 3
BEGIN_SCAN 4

I am trying to get all the values between BEGIN_DATA and END_DAT. In this textfile which is actually bigger this piece of text repeats itself so I am trying to desing a code which reads the values between BEGIN_DATA and END_DAT.
Can someone please help me!

Thanks in advance

Subject: Select data form text

From: Carlos Adrian Vargas Aguilera

Date: 24 Jun, 2009 20:36:01

Message: 2 of 3

"Paul " <pvankaam86@hotmail.com> wrote in message <h1td3l$dl8$1@fred.mathworks.com>...
> Hi,
>
> I have the following problem: I want to get values from a text file which looks as followed:
> CORRECTIONS=AIR_DENSITY_CORR;
> BEGIN_DATA
> -130.00 602.89E-03
> -120.00 605.77E-03
> -110.00 613.07E-03
> -100.00 623.12E-03
> -90.00 619.39E-03
> -80.00 624.38E-03
> -70.00 627.40E-03
> -60.00 628.70E-03
> -50.00 630.17E-03
> -40.00 630.05E-03
> -30.00 629.16E-03
> -20.00 627.44E-03
> -10.00 633.75E-03
> 0.00 627.81E-03
> 10.00 627.06E-03
> 20.00 628.62E-03
> 30.00 630.12E-03
> 40.00 625.19E-03
> 50.00 624.92E-03
> 60.00 626.39E-03
> 70.00 622.22E-03
> 80.00 619.85E-03
> 90.00 617.34E-03
> 100.00 611.50E-03
> 110.00 604.46E-03
> 120.00 599.90E-03
> 130.00 583.04E-03
> END_DATA
> END_SCAN 3
> BEGIN_SCAN 4
>
> I am trying to get all the values between BEGIN_DATA and END_DAT. In this textfile which is actually bigger this piece of text repeats itself so I am trying to desing a code which reads the values between BEGIN_DATA and END_DAT.
> Can someone please help me!
>
> Thanks in advance


Use readline to get from line 3 to the -4 (counted from the end of file)
http://www.mathworks.com/matlabcentral/fileexchange/20026

cell2mat(readline('yourfile.txt',[3;-4]))

Subject: Select data form text

From: Miroslav Balda

Date: 24 Jun, 2009 20:50:18

Message: 3 of 3

"Paul " <pvankaam86@hotmail.com> wrote in message <h1td3l$dl8$1@fred.mathworks.com>...
:
SNIP
:
> I am trying to get all the values between BEGIN_DATA and END_DAT. In this textfile which is actually bigger this piece of text repeats itself so I am trying to desing a code which reads the values between BEGIN_DATA and END_DAT.
> Can someone please help me!
>
> Thanks in advance

Hi,
There are severalpossible ways how to solve your problem:
1. The simplest way is to use the function fgetl, which reads the file line by line, and you may test the beginning and the end of useful data.
2. It is possible to use the function ffread:
    http://www.mathworks.com/matlabcentral/fileexchange/9034
Hope it helps.

Mira

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
readline Carlos Adrian Vargas Aguilera 24 Jun, 2009 16:39:07
file Carlos Adrian Vargas Aguilera 24 Jun, 2009 16:39:07
ascii Carlos Adrian Vargas Aguilera 24 Jun, 2009 16:39:07
text Carlos Adrian Vargas Aguilera 24 Jun, 2009 16:39:07
rssFeed for this Thread

Contact us