selik / xport

Python reader and writer for SAS XPORT data transport files.
MIT License
49 stars 24 forks source link

module 'xport' has no attribute 'XportReader' #55

Closed emmacwx1 closed 2 years ago

emmacwx1 commented 3 years ago

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?

selik commented 3 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

selik commented 3 years ago

I hope you don't mind the dependency on Pandas. Were you using Pandas already?

selik commented 2 years ago

@emmacwx1 I'm curious, where did you find the example code that you tried? Were those instructions from the CDC?

selik commented 2 years ago

I changed the interface

Actually, the old interface is still supported. I think you meant xport.Reader or xport.DictReader.

selik commented 2 years ago

I went ahead and tossed in xport.XportReader as an alias for xport.Reader, just in case.