tags:

views:

31

answers:

1

i want ro remove specific lines from the following csv file :

"Title.XP PoseRank" 

1VDV-constatomGlu-final-NoGluWat. 

1VDV-constatomGlu-final-NoGluWat. 

P6470-Usha.1 

P6470-Usha.2 

P6470-Usha.3 

P6470-Usha.4 

P6470-Usha.5 

P6515-Usha.1 

P6515-Usha.2 

P6517.1 

P6517.2 

P6517.3 

P6517.4 

P6517.5 

P6553-Usha.1 

P6553-Usha.2 

P6553-Usha.3 

i want to remove the lines that begin with 1VDV-constatomGlu-final-NoGluWat.

+1  A: 

The right solution is to use csv parser(i didn't test this code):


writer = csv.writer(open('corrected.csv'))
for row in csv.reader('myfile.csv'):
    if not row[0].startswith('1VDV-constatomGlu-final-NoGluWat.'):
        writer.writerow(row)
writer.close()

You can use also regular expression or some string manipulations but there is the risk that after your transformations the file will be no longer in csv format

Mykola Kharechko