ecshreve / jcgo

json to csv converter written in golang

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

jcgo

Go GoDoc Go Report Card Go Version codecov

Description

JSON to CSV converter in Golang.

Note: at this time, this converter doesn't implement the full JSON spec. (it doesn't currently handle arrays of scalar values, only arrays of map[string]interface{})

Usage

jcgo reads JSON from the file specified as a command line argument, parses the JSON, and writes the data to a CSV file.

> git clone https://github.com/ecshreve/jcgo.git
> cd jcgo
> make build
> bin/jcgo jsontestlocal.json jsontestlocal.output.csv
2020/07/24 18:39:22 generated csv file: jsontestlocal.output.csv

> cat jsontestlocal.output.csv | column -t -s ,
afterState_arrivedAt  afterState_departureTimeMs  afterState_destinationName  afterState_id  afterState_jobState  beforeState_arrivedAt  beforeState_departureTimeMs  beforeState_destinationName  beforeState_id  beforeState_jobState  changedAtMs    events_eventAt  events_eventType  id
0                     0                           CARI307                     4337769816     4                    0                      0                            CARI307                      4337769816      4                     1591056576414  1591056576414   0                 4333023554
1591034132029         1591034209011               JASON077                    4337769817     3                    1591034132029          1591034209011                JASON077                     4337769817      3                     1591056576414  1591056576414   0                 4333023554

reference

Googling

Here's an abbreviated list of the things I googled while making this (in no particular order).

  • json to csv
  • arbitrary json to csv
  • parse json golang
  • parse nested json
  • json to csv golang github
  • json spec
  • graphql json results
  • write to csv golang
  • golang parse command line args
  • golang flag package
  • golang use flags in test
  • longest common prefix
  • golang module
  • golang project organization
  • golang remove dependencies from module
  • go install vs go build
  • godoc json
  • godoc csv
  • golang stringer
  • golang interface inheritance
  • golang init function
  • golang sort custom type
  • golang embedded struct ... and many, many more

About

json to csv converter written in golang

License:MIT License


Languages

Language:Go 98.7%Language:Makefile 1.3%