0
I’m writing a script that joins all files of the same format into a folder and creates a single CSV and I want to send that CSV to the database. As new files enter this folder, CSV will always create new lines.
However, I am using this command to send the files to the database..
conn = psycopg2.connect(host="",database="",user="",password="")
cur = conn.cursor()
with open('extratos.csv', 'r') as f:
cur.copy_from(f, 'extratos', sep=',')
conn.commit()
But every time script wheel it reads the CSV file from the beginning and accuses that the first line is already in the database. How do I send only the new inserted lines?
I could not make this script only search for Csvs that have not yet been processed?
– Woss
Place a part of the CSV files to illustrate its structure.
– Carlos H Marques
@Andersoncarloswoss, CSV is unique. It joins all ofx files into a single CSV
– Rafaela Fracalossi