Exporting my python dataframe to SPSS gives me extra variables coming from too-long strings

I have an SPSS file where some variables contain long strings. When I import the data into python, everything runs smoothly. However, when I export my dataframe from python to SPSS, I suddenly see 43 extra variables in my SPSS dataset.

I guess the extra variables come from strings that are too long. My string variables are divided into 3 or 4 variables in the exported SPSS file.

How can I prevent this from happening?

The encoding is ‘utf-8’ and this is my export code:

%% Export pyreadstat.write_sav(recordings, export_result_path, compress =True , column_labels = meta.column_names_to_labels , variable_value_labels = meta.variable_value_labels

My guess is that this is an SPSS problem. You should ask them why they are splitting long strings into multiple variables.

Can you replicate this error using minimal data, say, one row with two variables, but the second variable is very long and gets changed to two or three variables in SPSS?

What does the %%Export line do? That’s not Python code, where are you typing it?

Can you strip your dataset to a single entry with the longest single variable? That will allow you to compare the original variable with the extra(s) and see if they’re parts of the same variable.