python - How to remove a cell of certain value from a CSV file -
i've csv file has got single cell @ last row. need find delete. e.g.
total1254612
the value of total won't same time causing problem.
you can leverage fact know there 1 value , first 5 letters 'total'
. rewrite lines don't meet these conditions new file:
f_original = open(fname, 'r') f_new = open(fname+'_new.csv', 'w') #iterate through lines line in f_original: if line.startswith('total'): f_new.write(line) f_original.close() f_new.close()
Comments
Post a Comment