j2tn/README.md

65 lines
1.2 KiB
Markdown
Raw Permalink Normal View History

2023-06-02 08:59:57 +00:00
# j2tn
2023-06-04 16:51:00 +00:00
Prototype for a semi-normalized way to convert a nested JSON document to CSV
2023-06-04 17:22:46 +00:00
## Requirements
2023-06-04 16:51:00 +00:00
You will need to install the following Perl modules
- YAML
- JSON
- Text::CSV_XS
For most operating systems this can be achieved by install the following a packages
- `perl-json`
- `perl-yaml`
- `perl-text-csv-xs` or `perl-text-csv`
2023-06-04 17:22:46 +00:00
## Examples for Linux
2023-06-04 17:32:27 +00:00
### help
#### command
2023-06-04 17:22:46 +00:00
```bash
./j2tn.pl help
```
2023-06-04 17:32:27 +00:00
#### output
2023-06-04 17:22:46 +00:00
```text
./j2tn.pl command [options,...] [arguments,...]
commands:
to-csv in-file-name out-file-name
use - for the out-file-name to go to std-out
debug [debug-bit-flag] command
1 => function calls
2 => current location
4 => parsed json
8 => unparsed json
16 => internal processed data just before output
speak command
echo the command
```
2023-06-04 17:32:27 +00:00
### to-csv
#### command
```bash
./j2tn.pl to-csv <(echo '[{"column1":"data1","column2":[1,2],"column3":3}]') -
```
#### output
```csv
_normlized_,column3,column1,column2
"{""column2"":[1,2]}",3,data1,"1; 2"
```
## Note
To manipulate the `csv` file I suggest `xsv`
2023-06-04 17:35:38 +00:00
- [xsv Source](https://github.com/BurntSushi/xsv)
2023-06-04 17:44:28 +00:00
- [xsv Binary Release](https://github.com/BurntSushi/xsv/releases)
2023-06-04 17:32:27 +00:00