Extract particular data from a text file

View: New views
3 Messages — Rating Filter:   Alert me  

Extract particular data from a text file

by du :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I have a text file which contains report of students(boys and girls)
of a school.
I want only the boys information.
For example,

Data.txt:
   This is the info about boys of primary school
ABCD 10 30
BCDE 11 32
CDEF 10 31

   This is the info about boys of secondary school
DEFG 12 33
EFGH 10 35
FGHI 10 32

   This is the info about girls of primary school
GHIJ 10 34
HIJK 11 35
IJKL 10 30

   This is the info about girls of secondary school
JKLM 11 28
KLMN 12 29
LMNO 10 32



What I want to extract is:

ABCD 10 30
BCDE 11 32
CDEF 10 31
DEFG 12 33
EFGH 10 35
FGHI 10 32

(The complete boys info records and only records)
whenever it encounters the word "girls" in the text file, it should
reject all the text following it.
how can I do it using a batch file?

Thanks in advance,
Du~


Re: Extract particular data from a text file

by foxidrive-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Can I have actual data, or obscured data (names changed) but in the actual
format?

On Thu, 03 Jan 2008 22:21:55 -0000, "raj_iitkgp2001"
<rpalantla@...> wrote:

>I have a text file which contains report of students(boys and girls)
>of a school.
>I want only the boys information.
>For example,
>
>Data.txt:
>   This is the info about boys of primary school
>ABCD 10 30
>BCDE 11 32
>CDEF 10 31
>
>   This is the info about boys of secondary school
>DEFG 12 33
>EFGH 10 35
>FGHI 10 32
>
>   This is the info about girls of primary school
>GHIJ 10 34
>HIJK 11 35
>IJKL 10 30
>
>   This is the info about girls of secondary school
>JKLM 11 28
>KLMN 12 29
>LMNO 10 32
>
>
>
>What I want to extract is:
>
>ABCD 10 30
>BCDE 11 32
>CDEF 10 31
>DEFG 12 33
>EFGH 10 35
>FGHI 10 32
>
>(The complete boys info records and only records)
>whenever it encounters the word "girls" in the text file, it should
>reject all the text following it.
>how can I do it using a batch file?
>
>Thanks in advance,
>Du~
>


Re: Extract particular data from a text file

by inferno1424 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a similar question like the user.

Attached is a file that is output from registry.  It contains 4 spaces at the beginning.  What I would like is to capture the information between the brackets { } (and including the brackets) and assign it to a variable.

Any ideas on how I would do this?

*Note the values between the brackets may change based on when the output is generated.  
new.txt

Any help would be appreciated.

foxidrive-5 wrote:
Can I have actual data, or obscured data (names changed) but in the actual
format?

On Thu, 03 Jan 2008 22:21:55 -0000, "raj_iitkgp2001"
<rpalantla@drivefinancial.com> wrote:

>I have a text file which contains report of students(boys and girls)
>of a school.
>I want only the boys information.
>For example,
>
>Data.txt:
>   This is the info about boys of primary school
>ABCD 10 30
>BCDE 11 32
>CDEF 10 31
>
>   This is the info about boys of secondary school
>DEFG 12 33
>EFGH 10 35
>FGHI 10 32
>
>   This is the info about girls of primary school
>GHIJ 10 34
>HIJK 11 35
>IJKL 10 30
>
>   This is the info about girls of secondary school
>JKLM 11 28
>KLMN 12 29
>LMNO 10 32
>
>
>
>What I want to extract is:
>
>ABCD 10 30
>BCDE 11 32
>CDEF 10 31
>DEFG 12 33
>EFGH 10 35
>FGHI 10 32
>
>(The complete boys info records and only records)
>whenever it encounters the word "girls" in the text file, it should
>reject all the text following it.
>how can I do it using a batch file?
>
>Thanks in advance,
>Du~
>
LightInTheBox - Buy quality products at wholesale price!