Skip to content

Latest commit

 

History

History
44 lines (38 loc) · 1.43 KB

README.md

File metadata and controls

44 lines (38 loc) · 1.43 KB

JsonCsvConverter.jl

Utility library for converting JSON to CSV, and vice versa.

Features

This module can convert JSON files to CSV, and vice versa. When converting from JSON to CSV, nestings are written as json-encoded strings in the output CSV. In order to get back to the original JSON file from a CSV, therefore, you should pass parse_nested_json=true to the convert function. See Usage.

Installation

Since this is an unregistered package, you can install it from the julia prompt as follows:

  • over SSH (recommended):
if get(Pkg.installed(), "JsonCsvConverter", false) == false
    Pkg.clone("[email protected]:peterbrescia/JsonCsvConverter.jl")
end
  • over HTTPS:
if get(Pkg.installed(), "JsonCsvConverter", false) == false
    Pkg.clone("https://github.com/peterbrescia/JsonCsvConverter.jl")
end

Dependencies

Dependencies can be found in the REQUIRE file. Package dependencies should install automatically upon installing this module. Requires Julia v0.5.

Usage

Convert CSV to JSON:

using JsonCsvConverter
c = JsonCsvConverter.Converter()
c.convert("in.csv", "out.json")

Convert JSON to CSV:

using JsonCsvConverter
c = JsonCsvConverter.Converter()
c.convert("in.json", "out.csv")

Options

  • When parsing a CSV that contains JSON-encoded fields, you can pass parse_nested_json=true to decode these fields:
convert("in.csv", "out.json", parse_nested_json=true)