Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python csv delete specific row

lines = list()
memberName = input("Please enter a member's name to be deleted.")
with open('mycsv.csv', 'r') as readFile:
    reader = csv.reader(readFile)
    for row in reader:
        lines.append(row)
        for field in row:
            if field == memberName:
                lines.remove(row)

with open('mycsv.csv', 'w') as writeFile:
    writer = csv.writer(writeFile)
    writer.writerows(lines)
Comment

PREVIOUS NEXT
Code Example
Python :: python distance of coordinates 
Python :: text to binary python 
Python :: python product of list 
Python :: write geopands into postgres python 
Python :: reject invalid input using a loop in python 
Python :: how does sns boxplot determine outliers 
Python :: python code to wait 
Python :: revesing case python 
Python :: how to clear screen python 
Python :: print a to z in python 
Python :: python check is admin 
Python :: python how to remove last letter from string 
Python :: django datetimefield default 
Python :: tqdm gui 
Python :: Remove the Unnamed column in pandas 
Python :: filter rows pandas 
Python :: np random array 
Python :: numpy stdev 
Python :: how to add and subtract days datetime python 
Python :: discord.py commands.group 
Python :: char list 
Python :: segregate list in even and odd numbers python 
Python :: django foreign key error Cannot assign must be a instance 
Python :: pandas merge dataframes from a list 
Python :: argparse multiple arguments as list 
Python :: How to normalize the data to get to the same range in python pandas 
Python :: django get user model funciton 
Python :: discord.py how to give a user a role 
Python :: decode base64 with python 
Python :: how to get user ip in python 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =