Closed emmacwx1 closed 2 years ago
Sorry, I changed the interface. I updated the README, so I think it'll explain it: https://github.com/selik/xport#reading-xpt
I hope you don't mind the dependency on Pandas. Were you using Pandas already?
@emmacwx1 I'm curious, where did you find the example code that you tried? Were those instructions from the CDC?
I changed the interface
Actually, the old interface is still supported. I think you meant xport.Reader
or xport.DictReader
.
I went ahead and tossed in xport.XportReader
as an alias for xport.Reader
, just in case.
I tried to convert NHANES data in xpt format into csv format in Jupyter notebook, and have installed xport with the following code: `import sys !{sys.executable} -m pip install xport
import xport, csv with xport.XportReader('MCQ_J.xpt') as reader: with open('MCQ_J.csv', 'rb') as out: writer = csv.DictWriter(out, [f['name'] for f in reader.fields]) for row in reader: writer.writerow(row)`
but I have the error that "module 'xport' has no attribute 'XportReader'", was my download package wrong or do you have advice on how to solve this?