I have data in this format, which is stored in a csv file: 3;6/3/2021;B;12/06/2021;BNP FP E;P;12;12;CONDORI;12;9:55:29;ETF;MINE;
I would like to separate this string into new cells of a each row on every semicolon detected in the same csv file.
Current code:
import sys, psycopg2
conn = psycopg2.connect("dbname=name user=userpassword=password")
cur = conn.cursor()
sql = "COPY (SELECT * FROM trades WHERE \"DATE_TRADE\" = '6/3/2021') TO STDOUT WITH CSV DELIMITER ';'"
with open(r'Y:\RESULT.csv', "a+") as file:
cur.copy_expert(sql, file)
array = file.readlines()
array = [row.split(';') for row in array]
Yields a file that has all the records but not separated on each semi-colon
Any help is greatly appreciated