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

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

Closed
emmacwx1 opened this issue Oct 19, 2020 · 5 comments
Closed

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

emmacwx1 opened this issue Oct 19, 2020 · 5 comments

Comments

@emmacwx1
Copy link

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
Copy link
Owner

selik commented Oct 20, 2020

Sorry, I changed the interface. I updated the README, so I think it'll explain it: https://github.com/selik/xport#reading-xpt

@selik
Copy link
Owner

selik commented Oct 20, 2020

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

@selik
Copy link
Owner

selik commented Dec 25, 2021

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

@selik
Copy link
Owner

selik commented Dec 25, 2021

I changed the interface

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

@selik selik closed this as completed Dec 25, 2021
selik added a commit that referenced this issue Dec 25, 2021
Issue #55 suggests that an old version of `xport` may have had an
`XportReader` class.  I can't remember that, but I figure it's easy
enough to toss it in.
@selik
Copy link
Owner

selik commented Dec 25, 2021

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

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

2 participants