You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using pyreadstat to read a SAV file, add columns, and save back, the output file size increases substantially without a proportional increase in actual data content.
Detailed Reproduction Steps
Read SAV file with encoding detection
`import pyreadstat
import chardet
Encoding detection
with open(file_path, 'rb') as file:
raw_data = file.read(10000)
result = chardet.detect(raw_data)
detected_encoding = result['encoding'] or 'utf-8'
Read file
sav_df, meta = pyreadstat.read_sav(file_path, encoding=detected_encoding)
Description
When using pyreadstat to read a SAV file, add columns, and save back, the output file size increases substantially without a proportional increase in actual data content.
Detailed Reproduction Steps
Read SAV file with encoding detection
`import pyreadstat
import chardet
Encoding detection
with open(file_path, 'rb') as file:
raw_data = file.read(10000)
result = chardet.detect(raw_data)
detected_encoding = result['encoding'] or 'utf-8'
Read file
sav_df, meta = pyreadstat.read_sav(file_path, encoding=detected_encoding)
Add new columns
new_column_labels = meta.column_labels.copy()
new_value_labels = meta.variable_value_labels.copy()
Write file back
temp_sav_path = sav_file_path.replace('.sav', '_updated.sav')
pyreadstat.write_sav(
sav_df,
temp_sav_path,
column_labels=new_column_labels,
variable_value_labels=new_value_labels
)
Environment Details
pyreadstat version: 1.2.8
Platform: macOS
Python version: 3.9.18
The text was updated successfully, but these errors were encountered: