Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

write_sav: variable_display_width always 0 #72

Closed
josmos opened this issue Aug 28, 2020 · 4 comments
Closed

write_sav: variable_display_width always 0 #72

josmos opened this issue Aug 28, 2020 · 4 comments
Labels
bug Something isn't working requires changes in Readstat waiting for changes in the C library Readstat

Comments

@josmos
Copy link

josmos commented Aug 28, 2020

The Parameter for setting the display width is ignored:

import pandas as pd
import pyreadstat

df = pd.DataFrame({
    "v1": {
        "10001": """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas ac pretium sem. Fusce aliquet
        augue rhoncus consequat pulvinar. In est ex, porta congue diam sed, laoreet suscipit purus. Phasellus mollis
        lobortis tellus at vehicula. Etiam egestas augue id massa bibendum volutpat id et ipsum. Praesent ut lorem
        rhoncus, pharetra risus sed, pharetra sem. In pulvinar egestas erat, id condimentum tortor tempus sed. Duis
         ornare lacus ut ligula congue, non convallis urna dignissim. Etiam vehicula turpis sit amet nisi finibus
         laoreet. Duis molestie consequat nulla, non lobortis est tempus sit amet. Quisque elit est,
         congue non commodo vitae, porttitor ac erat. """,
        "10002": "fgsdghshsgh",
        "10003": "gsfdgsdg",
    },
    "v2": {
        "10001": "gsfdgsfdgsfg",
        "10002": "fgsdghshsgh",
        "10003": "gsfdgsdg",
    },

})

pyreadstat.write_sav(df, "export.sav", variable_display_width={"v1": 100})

df, meta = pyreadstat.read_sav("export.sav")
print(meta.variable_display_width)
#{'v1': 0, 'v2': 0}
@ofajardo
Copy link
Collaborator

Thanks for the report. It is the length of the string, if it is less than 256 characters, then variable_display_width is written correctly. If 256 or more then you get 0.

This looks like coming from the C code (Readstat, so I'll file an issue over there on your behalf)

@ofajardo
Copy link
Collaborator

Issue in Readstat: WizardMac/ReadStat#210

@ofajardo ofajardo added bug Something isn't working requires changes in Readstat waiting for changes in the C library Readstat labels Aug 28, 2020
@ofajardo
Copy link
Collaborator

Solved on dev, although the max width right now is 255 (should be much larger)

@ofajardo
Copy link
Collaborator

this is now fully solved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working requires changes in Readstat waiting for changes in the C library Readstat
Projects
None yet
Development

No branches or pull requests

2 participants