Q:

I want to delete rows of a csv file which contain " / " in it using python

I want to delete rows of a csv file which contain " / " in it.
import csv
with open("test.csv", 'r') as infile , open("test2.csv", 'w') as outfile:
    reader=csv.reader(infile)
    writer=csv.writer(outfile)
    for line in reader:
        if "/" not in line:
            writer.writerow(line)

This not working .
Sample data

182 /api/PostAppDetails?loanSeqId=12067,1,12.136
182 /api/PostAppDetails?loanSeqId=12068,1,17.509

A:

Your sample data makes me wonder why you are treating them as CSV files
Can't you just do
with open("test.csv", 'r') as infile , open("test2.csv", 'w') as outfile:
    for line in infile:
        if "/" not in line: 
            outfile.write(line)

Note: your code is probably failing because the CSV code is returning a line as an array of strings. So you are checking if the array has one element equal to "/"

