jsplit

command module
v0.0.0-...-a669bc7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

README

JSplit

JSplit is a program that can take large JSON files and split them up into a root.json files and several .jsonl files. The program takes the list items in the root of the JSON document and creates jsonl files containing the data from those lists. The files representing list data take the form [key]_%02d.jsonl where [key] is the key for the list being processed and %02d will be sequential indexes for the files. Order of data in the lists is maintained across the files. Non-list items in the root of the JSON document will be written to a file root.json

Installation

To install the application you will need Golang installed and you will need to clone this repository. Once you have cloned the repository cd into the cloned jsplit directory and run:

go install .

Usage

jsplit -file <input_file> [-output <output_path>]

  • file - (Required) Name of the json or or gz encoded json file being split into jsonl files
  • output - (Optional) Output directory. If not provided, a directory will be created based on the name of the input file. For example, if the file myfile.json is being split and an output direce a directory named myfile_json would be created and output would be written there.

Example

example.json
{
  "string": "val1",
  "number": 0,
  "bool": true,
  "object": {
    "key": "value"
  },
  "list": [
    {"idx": 0, "name":  "alex"},
    {"idx": 1, "name":  "brian"},
    {"idx": 2, "name":  "charles"},
  ]
}
Example Usage

jsplit -file example.json

Example Output files
example_json/root.json
{
  "string": "val1",
  "number": 0,
  "bool": true,
  "object": {"key": "value"}
}
example_json/list_00.json
{"idx": 0, "name":  "alex"}
{"idx": 1, "name":  "brian"}
{"idx": 2, "name":  "charles"}

In the case that a jsonl output file exceeds 4GB a new file will be created with the next sequence number. In this case the next output file would be list_01.jsonl

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL