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

Numeric variables files generated from CSV input always have decimals #281

Open
eirki opened this issue Aug 4, 2022 · 1 comment
Open
Labels

Comments

@eirki
Copy link

eirki commented Aug 4, 2022

I am trying to generate SPSS and Stata files using CSV files + JSON metadata as input as described here. However, in the generated files, every numeric variable has decimals, so 1, 2, 3 become 1.0, 2.0, 3.0.

Steps to reproduce:

inputdata.csv:

"var_a","var_b"
1,1.1
2,2.2
3,3.3

meta.json:

{
    "type": "SPSS",
    "variables": [
        {
            "type": "NUMERIC",
            "name": "var_a",
            "decimals": 0
        },
        {
            "type": "NUMERIC",
            "name": "var_b",
            "decimals": 2
        }
    ]
}

cmd:
readstat inputdata.csv meta.json outputdata.sav

To test, check in SPSS or with pyreadstat:
python -c "import pyreadstat; print(pyreadstat.read_sav('outputdata.sav')[1].original_variable_types)"

My output:
{'var_a': 'F8.2', 'var_b': 'F8.2'}

var_a should be F8.0.

I've poked around with git bisect, and it seems this is a regression introduced in 93036b0. When I checked out the repo from one commit earlier (1b64538) and reran with the same input I got

{'var_a': 'F8.0', 'var_b': 'F8.2'}

Very grateful for any assistance with generating files without all those .0 decimals.

@evanmiller evanmiller added the CLI label Jan 15, 2023
@evanmiller
Copy link
Contributor

Duplicate of #177

@evanmiller evanmiller marked this as a duplicate of #177 Jan 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants