xport icon indicating copy to clipboard operation
xport copied to clipboard

Improve error message when trying to open a CPORT file

Open cmdugan13 opened this issue 3 years ago • 7 comments

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

cmdugan13 avatar Jan 18 '22 20:01 cmdugan13

@cmdugan13 Do you mind pasting the code you used?

selik avatar Jan 19 '22 02:01 selik

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

selik avatar Jan 19 '22 02:01 selik

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

cmdugan13 avatar Jan 19 '22 02:01 cmdugan13

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

selik avatar Jan 19 '22 05:01 selik

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

cmdugan13 avatar Jan 19 '22 13:01 cmdugan13

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 avatar Jan 19 '22 15:01 selik

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

selik avatar Jan 19 '22 15:01 selik