A tool to convert a csv file to multiple json files.
Given a csv file of the form
key;en;de;
helloWorld;Hello World!;Hallo Welt!;
the following json files
{
"helloWorld": "Hello World!"
}
{
"helloWorld": "Hallo Welt!"
}
are generated.
Note that the column headers en
, de
are automatically inferred from json basename.
Firstly, add the package as a dev dependency:
dev_dependencies:
csv_to_json:
git:
url: https://github.com/defuncart/csv_to_json
Ensure that your current working directory is the project root, then run the following command:
dart run csv_to_json --file_path="assets/test.csv" --output_dir="assets/json/" --csv_delimiter=";" --start_index="1"
Setting | Description |
---|---|
file_path | A path to the csv file. |
output_dir | A dir to save the generated json files. |
csv_delimiter | A delimiter to separate columns in the input CSV file. Defaults to ; . |
start_index | An index to begin parsing. Defaults to 1 . |
The package can be global activated and used as a cli tool as follows:
dart pub global activate -sgit https://github.com/defuncart/csv_to_json
csv_to_json --file_path="assets/test.csv" --output_dir="assets/json/" --csv_delimiter=";" --start_index="1"
The package can be deactivated as follows:
dart pub global deactivate csv_to_json
Spotted any issues? Please open an issue on GitHub! Would like to contribute a new feature? Fork the repo and submit a PR!