Delete Or Extract Specific rows from txt file

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Delete Or Extract Specific rows from txt file

#1 Post by mohdfraz » 25 Mar 2015 01:52

Hi,

I have a lot of txt files to sort out so I need a batch file which can delete all the rows which are starting from "0,"
Or Extract rows data which are not starting from "0," and transfer it to another txt file.

Code: Select all

Custom Criteria,result1,result2,result3,result4,result5,result6,result7
14317543947,82337.5,467862.5,-385525,1005,61.791045,621,173.023378
14171331839,83237.5,469162.5,-385925,1003,62.21336,624,169.742544
14171331839,83237.5,469162.5,-385925,1003,62.21336,624,169.742544
12899993590,82250,460850,-378600,911,55.872667,509,172.161172
0,76087.5,521687.5,-445600,1121,48.706512,546,512.805392
0,76087.5,521687.5,-445600,1121,48.706512,546,512.805392
0,78475,425650,-347175,852,53.873239,459,481.811205
0,78475,425650,-347175,852,53.873239,459,481.811205


Thanks

npocmaka_
Posts: 516
Joined: 24 Jun 2013 17:10
Location: Bulgaria
Contact:

Re: Delete Or Extract Specific rows from txt file

#2 Post by npocmaka_ » 25 Mar 2015 02:05


mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Delete Or Extract Specific rows from txt file

#3 Post by mohdfraz » 25 Mar 2015 02:14

npocmaka_ wrote:check this : viewtopic.php?f=3&t=6184&start=0


This option will find key word in the whole row. But my issue is I want to check the key word in the First column only. If I use this option it will extract all rows.

Thanks

dbenham
Expert
Posts: 2461
Joined: 12 Feb 2011 21:02
Location: United States (east coast)

Re: Delete Or Extract Specific rows from txt file

#4 Post by dbenham » 25 Mar 2015 06:03

Preserve only rows starting with "0"

Code: Select all

findstr "^0" test.txt >test_only_0_start.txt

Delete rows starting with "0"

Code: Select all

findstr /v "^0" test.txt >test_no_0_start.txt


Dave Benham

mohdfraz
Posts: 69
Joined: 29 Jun 2011 11:16

Re: Delete Or Extract Specific rows from txt file

#5 Post by mohdfraz » 25 Mar 2015 07:13

dbenham wrote:Preserve only rows starting with "0"

Code: Select all

findstr "^0" test.txt >test_only_0_start.txt

Delete rows starting with "0"

Code: Select all

findstr /v "^0" test.txt >test_no_0_start.txt


Dave Benham


Dave Benham,

You are the MAN..........

It worked like a charm. One line solutions, Now thats awesome.

Million thanks to you.

Post Reply