This commit is contained in:
Yam ZhengLim
2022-10-01 12:41:54 +08:00
parent 81c1240624
commit e938412405
@@ -37,11 +37,8 @@ def mysql_dict_sql_to_csv(SQL_DICT, path, mysqldb, mysqlcursor):
filename = '/{}_{}.csv'.format(mysqldbname, tablename)
headers = [col[0] for col in mysqlcursor.description] # get headers
mysqlresult.insert(0, tuple(headers))
with open(concat(path,filename), 'r') as infile, open(concat(path,filename), 'w') as outfile: #REMOVE ALL |
temp = infile.read().replace("|", "/")
outfile.write(temp)
fp = open(concat(path,filename), 'w', newline = '', encoding = 'utf-8-sig')
myFile = csv.writer(fp,delimiter='|',quotechar="'")
myFile = csv.writer(fp,delimiter='|',quotechar='"', quoting=csv.QUOTE_ALL)
myFile.writerows(mysqlresult)
fp.close()