Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encode char error #104

Closed
doublebro opened this issue Jan 22, 2023 · 1 comment
Closed

Encode char error #104

doublebro opened this issue Jan 22, 2023 · 1 comment

Comments

@doublebro
Copy link

doublebro commented Jan 22, 2023

Tried to export a NHANES data file to csv and encountered the error.

Data file available at:
https://wwwn.cdc.gov/nchs/nhanes/search/datapage.aspx?Component=Dietary&Cycle=2017-2020 (at DSII Data [XPT - 74 MB]

Bash CLI:
bash-3.2$ python -m xport SAS_NHANES_Data/DSII.XPT > SAS_NHANES_Data/DSII.csv
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"main", fname, loader, pkg_name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/SAS_NHANES_Data/xport-2.0.2/xport.py", line 815, in
print(','.join(map(str, row)))
UnicodeEncodeError: 'ascii' codec can't encode character u'\x92' in position 55: ordinal not in range(128)

@doublebro
Copy link
Author

Apologies, I noticed my MacOS python pointed to version 2.7.16.

I upgraded to version 3.11 and used the below command which worked fine.
python3 -m xport SAS_NHANES_Data/DSPI.XPT > SIG731/SAS_NHANES_Data/DSPI.csv

Closing this as it is a non-issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant