ReadStat icon indicating copy to clipboard operation
ReadStat copied to clipboard

Using the CSV input always defaults to 2 decimal variable

Open jrking4 opened this issue 6 years ago • 6 comments

When trying to use the following: readstat <input file.csv> <input metadata.json> <output file>

I define my NUMERIC variable with the property "decimals": 0 however ReadStat simply ignores anything I put in that property and just defaults to 2 decimals.

jrking4 avatar Feb 28 '19 16:02 jrking4

I also have the same problem.

smartepsh avatar Mar 21 '19 10:03 smartepsh

What is your output format? SAV, DTA, etc

evanmiller avatar Sep 09 '20 18:09 evanmiller

SAV in my case.

smartepsh avatar Sep 10 '20 11:09 smartepsh

Any ideas, @ivarref?

evanmiller avatar Sep 10 '20 14:09 evanmiller

A Simple Example

csv data file:

Q,customized
1,1.2345678

meta json:

{
  "type": "SPSS",
  "variables": [
    {
      "decimals": 5,
      "label": "customized",
      "name": "customized",
      "type": "NUMERIC"
    },
    {
      "categories": [
        {
          "code": 1,
          "label": "male"
        },
        {
          "code": 2,
          "label": "female"
        }
      ],
      "decimals": 0,
      "label": "Q",
      "name": "Q",
      "type": "NUMERIC"
    }
  ]

in spss

The decimals value of both variables is 2.

image

smartepsh avatar Sep 10 '20 15:09 smartepsh

Hi, I don't have good idea. I'm away from my job until end of October, maybe I can investigate further then.

I do remember doing some extra fixes (3 commits) that never went into WizardMac:master: https://github.com/ivarref/ReadStat

Particularly using jasmine strict mode to avoid some JSON boundary parsing errors: https://github.com/ivarref/ReadStat/commit/b3d44c08618d86ce9523193c95a16b0564e9d9a4

Could that be relevant?

Regards.

Edit: JSON boundary parsing errors, not CSV.

ivarref avatar Sep 14 '20 14:09 ivarref