Skip to content

Prep JSON data for stan #392

Description

@xvzftube

I have been stringing a shell script in with mlr to prepare the data for stan. I wanted to open this as a feature request. As oppose to my csv2json.sh script maybe a flag —json-cells-to-arrays or any other more suitable name.

wget https://gist.githubusercontent.com/seankross/a412dfbd88b3db70b74b/raw/5f23f993cd87c283ce766e7ac6b329ee7cc2e1d1/mtcars.csv

mlr --csv --ojson --jlistwrap cut -f mpg,wt mtcars.csv | ./csv2json.sh > data.json

csv2json.sh Is a jq shell script


jq '. as $in
| reduce (.[0] | keys_unsorted[]) as $k ( {}; 
    .[$k] = ($in|map(.[$k] | (tonumber? // .))))'

As a reference this page shows the format of the json needed for CmdStan https://mc-stan.org/docs/2_25/cmdstan-guide/example-model-and-data.html

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions