TeX: Catch encoding exception for writing equation parse results
@@ -101,6 +101,7 @@ class ExtractSymbols(ArxivBatchCommand[ArxivId, SymbolData]):
with open(os.path.join(tokens_dir, "parse_results.csv"), "a") as results_file:
writer = csv.writer(results_file, quoting=csv.QUOTE_ALL)
+ try:
writer.writerow(
[
result.path,
@@ -110,6 +111,11 @@ class ExtractSymbols(ArxivBatchCommand[ArxivId, SymbolData]):
result.errorMessage,
]
)
+ except Exception: # pylint: disable=broad-except
+ logging.warning(
+ "Couldn't write parse results for arXiv %s: can't be converted to utf-8",
+ item,
+ )
if result.characters is not None and len(result.characters) > 0:
with open(os.path.join(tokens_dir, "tokens.csv"), "a") as tokens_file:
