0
I am starting learning in python and do not know how to continue this code.
I need to check the first column of a csv file, and if I don’t have a date in a cell in that column, insert the one that was passed as 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 arrived at this point, where he adds the 3° parameter even if the cell has "201" and still adds a "," (comma) at the end of the cell.
201 is the substring of a date, ex: 2018
What can I do to ignore the cell that has "201" and remove that comma at the end???
Post some lines of the file. Some that have the 201 and others that do not.
– Reginaldo Rigo