json2csv

command module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README

json2csv – Parse JSON files to CSV with data qualifier

Go version Go report Code coverage Wiki License

The parser can read given folder with *.json files, filtering and qualifying input data with intent & stop words dictionaries and save results to CSV files by given chunk size.

Minimal dependency on other Go packages, but maximum performance even on large amounts of the input JSON data.

⚡️ Quick start

First, download and install Go. Version 1.20 or higher is required.

Installation is done by using the go install command:

go install https://github.com/koddr/json2csv@latest

Prepare folder with your data source in the *.json format, create JSON files with intents and filter (for example, intents-file.json and filter-file. json). See the Wiki page to understand structures of JSON files and get general recommendations for preparing the input data.

Next, run json2csv parser with (or without) options:

json2csv \
  -json    /path/to/input/json/folder \
  -intents /path/to/intents-file.json \
  -filter  /path/to/filter-file.json \
  -output  /path/to/output/csv/folder \
  -content-field message \
  -min-word-len  5 \
  -chunk 1000

💡 Note: output CSV file has a default comma (,) separators between columns.

🧩 Options

  • -json [path] is an option to set a path to the folder with JSON source file(s) (see Wiki);
  • -intents [path] is an option to set a path to the file with intents (see Wiki);
  • -filter [path] is an option to set a path to the file with a filter (see Wiki);
  • -output [path] is an option to set a path to the output folder where the prepared CSV file(s) will be placed (see Wiki);
  • -content-field [string] is an option to set a name of the content field (attribute that contains string to qualify and filter) in JSON source file(s);
  • -min-word-len [int] is an option to set a min word length count to filter input words (if a word is smaller than this option, it will be skipped);
  • -chunk [int] is an option to set a chunk size for one CSV file;

✨ Solving case

Imagine that you have many JSON files of the same type in a folder on your computer. The structure of each such file is identical and can be described in a single Go structure.

But your task is not only to turn these files into a structured CSV, but also to make some qualification of incoming data based on dictionaries with intent.

The output should be CSV files (with a specified number of lines in each), where the first column contains the original phrases from JSON files, and the second column will contain the associated intents after qualification.

This is what this Go package solves! ✌️

⚠️ License

json2csv is free and open-source software licensed under the Apache 2.0 License, created and supported with 🩵 for people and robots by Vic Shóstak.

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