Example error
File "c:\Users\x\dev\DVT\Lib\site-packages\data_validation\util.py", line 32, in timed_call
result = fn(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^
File "c:\Users\x\dev\DVT\Lib\site-packages\data_validation\result_handlers\text.py", line 75, in print_formatted_
print(self._get_formatted(result_df))
File "c:\Users\x\dev\DVT\Lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\x81' in position 351: character maps to <undefined>
Suggested workaround from Windows Command Prompt (CMD):
set PYTHONIOENCODING=utf-8
data-validation validate row -sc=c1 -tc=c2 --tbls ... > "%output_dir%\dbo_tblbank.csv"
Potential code change
To prevent crashes on Windows when printing non-ASCII / UTF-8 characters to redirected standard output, text.py can safely reconfigure standard output to UTF-8 before calling print :
import sys
# Ensure stdout uses UTF-8 encoding so redirected files don't fail on Windows cp1252
if hasattr(sys.stdout, "reconfigure"):
sys.stdout.reconfigure(encoding="utf-8")
We should either document the workaround or implement the potential solution.
Example error
Suggested workaround from Windows Command Prompt (CMD):
Potential code change
To prevent crashes on Windows when printing non-ASCII / UTF-8 characters to redirected standard output,
text.pycan safely reconfigure standard output to UTF-8 before callingprint:We should either document the workaround or implement the potential solution.