SAS7BDAT file not readable
`import pyreadstat
file_path = r"C:\Users\YaoPeng\AppData\Local\Temp\raw_data\ae.sas7bdat"
encodings = ["utf-8", "gbk", "gb2312", "cp1252", "latin1", "iso-8859-1", "utf-16"] for enc in encodings: try: df, meta = pyreadstat.read_sas7bdat(file_path, metadataonly=True) print("Metadata read successfully, column name:", meta.column_names) except Exception as e: print("Metadata read failure, error message:", str(e)) print(f"Encoding {enc} failed")`
Hi! As shown in Figure 1, this is a sas7bdat data that I opened in variable view with the SAS System Viewer software, and I want to get this data, using python, Python 3.9.13,But running the appeal code results in an error,Error prompt :Metadata read failure, error message: Invalid file, or file has unsupported features,And attempts to implement multiple encoding formats have failed.However, I downloaded the official test file sample.sas7bdat from the git hub to run this code. So why is my own ae.sas7bdat file running this code error? In addition, their own ae.sas7bdat file can also be opened normally by SAS System Viewer software, but the official test file sample.sas7bdat cannot be opened normally by SAS System Viewer software.Tips as shown in Figure 2
pyreadstat version == 1.2.8
Traceback (most recent call last):
File "D:\python-testtest\main.py", line 6, in
thanks for the report. The problem seems to be coming from the underlaying C library Readstat. Feel free to report the issue there, it needs to be solved there first. It is unlikely that it is an encoding issue.
reported in https://github.com/WizardMac/ReadStat/issues/336
reading ae.sas7bdat solved on dev! feel free to test.
Regarding why sample.sas7bdat is not opening in your viewer, I don't know, that file was generated on SAS, so if it does not open, that is a problem beyond the scope of this project.
Possibly related to this: https://pharmasug.org/proceedings/2018/EP/PharmaSUG-2018-EP08.pdf
"The first question to ask is why SAS System Viewers cannot open datasets generated in SAS 9.4 ..."
solved on new version 1.3.0