jsonxlsx: json to xlsx converter

[ mit, program, text ] [ Propose Tags ]

json to xlsx converter


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1
Dependencies aeson (>=0.8.0.1), attoparsec, base (>=4.6 && <5), bytestring, containers, HUnit, old-time, optparse-applicative, scientific (>=0.3.3), string-qq, text, time, unordered-containers, vector, xlsx (==0.4.1) [details]
License MIT
Author Daniel Choi
Maintainer Mackey RMS
Category Text
Home page https://github.com/mackeyrms/jsonxlsx#readme
Bug tracker https://github.com/mackeyrms/jsonxlsx/issues
Source repo head: git clone https://github.com/mackeyrms/jsonxlsx
Uploaded by mackeyrms at 2017-03-20T01:05:41Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Executables jsonxlsx
Downloads 1425 total (6 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs not available [build log]
Last success reported on 2017-03-20 [all 3 reports]

Readme for jsonxlsx-0.1.0.1

[back to package description]

jsonxlsx

Transforms a standard JSON format to a Excel xlsx document.

This project is experimental; jsonxlsx's xlsx output has not been tested with Excel, only with OpenOffice.

Install

You must have a recent version of the Haskell Platform on your system.

A prerequisite is a the xlsx fork at https://github.com/danchoi/xlsx, which must be added to the cabal sandbox before building jsonxlsx. Here are the steps

git clone git@github.com/danchoi/xlsx
git clone git@github.com/danchoi/jsonxlsx
cd jsonxlsx
cabal update
cabal sandbox init
cabal sandbox add-source ../xlsx
cabal install --only-dependencies
cabal build

# Now copy dist/build/jsonxlsx/jsonxlsx to a location on your PATH

Usage

jsonxlsx

Usage: jsonxlsx [-a DELIM] FIELDS OUTFILE [--debug]
  Transform JSON object steam to XLSX. On STDIN provide an input stream of
  newline-separated JSON objects.

Available options:
  -h,--help                Show this help text
  -a DELIM                 Concatentated array elem delimiter. Defaults to
                           comma.
  FIELDS                   JSON keypath expressions
  OUTFILE                  Output file to write to. Use '-' to emit binary xlsx
                           data to STDOUT.
  --debug                  Debug keypaths

Example:

This is the input JSON object stream:

sample.json:

{
  "title": "Terminator 2: Judgement Day",
  "year": 1991,
  "stars": [
    {
      "name": "Arnold Schwarzenegger"
    },
    {
      "name": "Linda Hamilton"
    }
  ],
  "ratings": {
    "imdb": 8.5
  }
}
{
  "title": "Interstellar",
  "year": 2014,
  "stars": [
    {
      "name": "Matthew McConaughey"
    },
    {
      "name": "Anne Hathaway"
    }
  ],
  "ratings": {
    "imdb": 8.9
  }
}

This is the command to turn this stream into an XLSX file:

< sample.json jsonxlsx \
  'title:"Movie Title" year stars.name:"Movie Actors" ratings.imdb:"IMDB Score"' \
  movies.xlsx 

This is the output (movies.xlsx):

screen

See the README for jsontsv to see how to use jq to generate JSON object streams from nested JSON data structures.

Future improvements

The xlsx library that jsonxlsx uses to generate Excel output seems to have ways to control the column widths and other characteristics of the Excel spreadsheet. Contributors are welcome to add ways of controlling these parameters to jsonxlsx.