Page 1 of 1

Delete Or Extract Specific rows from txt file

Posted: 25 Mar 2015 01:52
by mohdfraz
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

Re: Delete Or Extract Specific rows from txt file

Posted: 25 Mar 2015 02:05
by npocmaka_

Re: Delete Or Extract Specific rows from txt file

Posted: 25 Mar 2015 02:14
by mohdfraz
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

Re: Delete Or Extract Specific rows from txt file

Posted: 25 Mar 2015 06:03
by dbenham
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

Re: Delete Or Extract Specific rows from txt file

Posted: 25 Mar 2015 07:13
by mohdfraz
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.