I'm trying to remove every row in multiple .csv files which contains empty cell. For example:
Data 1, Data 2, Data 3, Data 4
Value 1, Value 2, Value 3, Value 4
<empty cell>, Value 2, Value 3, Value 4 #Trying to remove this whole row
<empty cell>, Value 2, Value 3, Value 4 #Trying to remove this whole row
Value 1, Value 2, Value 3, Value 4
This is what I got so far:
import os
import csv
import argparse
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--input", required=True)
ap.add_argument("-o", "--output", required=True)
args = vars(ap.parse_args())
for file in os.listdir(args["input"]):
if file.endswith(".csv"):
with open(os.path.join(args["input"],file), 'r') as infile, open(os.path.join(args["output"], file), 'w') as outfile:
csv_reader = csv.reader(infile)
for line in csv_reader: ///This is where I get stuck
with open(os.path.join(args["output"], file), 'a') as outfile:
outfile.close()
any ideas? Thanks
','or whatever you want...