selik / xport

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

Improve error message when trying to open a CPORT file #86

Open cmdugan13 opened 2 years ago

cmdugan13 commented 2 years ago

Hello, thank you for this amazing package! I think I do require an update for version 8 XPORT. I am trying to download a file from cms and load it into a data frame, but I am unable to do so. I receive this error: ValueError: Document does not match SAS Version 5 or 6 Transport (XPORT) format right now I am using version 3.5.0

selik commented 2 years ago

@cmdugan13 Do you mind pasting the code you used?

selik commented 2 years ago

I should probably improve the README. Did you use xport.v89.load?

cmdugan13 commented 2 years ago

I don't, so it could be a version problem since it doesn't even show up in the directory ['Dataset', 'DictReader', ...... 'to_numpy', 'to_rows', 'v56', 'warnings']

Will check on that.

Edit: version 3.5.0

selik commented 2 years ago

Thanks for pointing that out. Please import xport.v89.

cmdugan13 commented 2 years ago

I made sure the version was upgraded, do it solved the missing module issue. I am back to receiving the ValueError: Document does not match SAS Version 5 or 6 Transport (XPORT) format error, though.

import xport.v89

with open('C2419P1M.XPORT', 'rb') as f:
    library = xport.v89.load(f)

Is this related to https://github.com/selik/xport/issues/6

selik commented 2 years ago

Rats. Seems like a bug. Could you share the result of f.read(800)? I'd like to see the header bytes of the file.

selik commented 2 years ago

Oh, if this is a CPORT file, then it's not yet supported, but the error message should be better.