I'm starting to learn in python and I do not know how to proceed with this code.
I need to check the first column of a csv file, and if it does NOT have a date in a cell of that column, insert the one that was passed as a parameter.
import csv
import sys
lendo_arquivo = csv.reader(open(sys.argv[1], 'rb'))
escrevendo_arquivo = csv.writer(open(sys.argv[2], 'wb'))
for linhas in lendo_arquivo:
if linhas[0] == "201":
pass
else:
escrevendo_arquivo.writerow([sys.argv[3] + ";"] + linhas)
I came to this point, where it adds the 3rd parameter even though the cell has "201" and still adds a "," (comma) at the end of the cell.
201 is the substring of a date, eg 2018
What can I do to bypass the cell that has "201" and remove that comma from the end ???