Skip to content

Commit

Permalink
fix: utf8 encoding check was still using NamedTemporaryFile technique
Browse files Browse the repository at this point in the history
that was supplanted by temporary directory approach introduced in https://github.com/dathere/datapusher-plus/pull/117/files
  • Loading branch information
jqnatividad committed Jan 15, 2024
1 parent cee3b0e commit d2a4304
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions datapusher/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -665,12 +665,13 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None):
"Normalizing/UTF-8 transcoding {} to CSV...".format(resource_format)
)

qsv_input_utf_8_encoded_csv = tempfile.NamedTemporaryFile(suffix=".csv")
qsv_input_utf_8_encoded_csv = os.path.join(temp_dir, 'qsv_input_utf_8_encoded.csv')

# using uchardet to determine encoding
file_encoding = subprocess.run(
[
"uchardet",
tmp.name
tmp
],
check=True,
capture_output=True,
Expand All @@ -691,9 +692,9 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None):
file_encoding.stdout,
"-t",
"UTF-8",
tmp.name,
tmp,
"--output",
qsv_input_utf_8_encoded_csv.name,
qsv_input_utf_8_encoded_csv,
],
check=True,
)
Expand All @@ -708,7 +709,7 @@ def _push_to_datastore(task_id, input, dry_run=False, temp_dir=None):
[
qsv_bin,
"input",
qsv_input_utf_8_encoded_csv.name,
qsv_input_utf_8_encoded_csv,
"--trim-headers",
"--output",
qsv_input_csv,
Expand Down

0 comments on commit d2a4304

Please sign in to comment.