Update csv handling
This commit is contained in:
@ -11,7 +11,7 @@ import ctypes.wintypes
|
||||
import hashlib
|
||||
import pypyodbc
|
||||
|
||||
import csv
|
||||
import utils
|
||||
|
||||
|
||||
IGNORED_NAMES = ['Windows', 'Program Files', 'Program Files (x86)', 'AppData']
|
||||
@ -138,11 +138,10 @@ def main() -> None:
|
||||
cur.execute(f"SELECT * FROM {t_name} ORDER BY `{desc[0][0]}`;")
|
||||
cols = [t[0] for t in cur.description]
|
||||
|
||||
with open(f'{args.output}/{t_name}.csv', 'wb+') as f:
|
||||
f.write((';'.join(cols) + '\n').encode('utf-8'))
|
||||
with utils.csv_open(f'{args.output}/{t_name}.csv') as f:
|
||||
f.header(cols)
|
||||
for row in cur:
|
||||
values = [csv.convert_value(val, table=t_name, column=col) for col, val in zip(cols, row)]
|
||||
f.write((';'.join(values) + '\n').encode('utf-8'))
|
||||
f.row((utils.convert_value(val, table=t_name, column=col) for col, val in zip(cols, row)), raw=True)
|
||||
|
||||
print(f'Exported {t_name} successfully!', flush=True)
|
||||
finally:
|
||||
|
Reference in New Issue
Block a user