A tool to convert multiple json files to csv.
Given json files of the form
{
"helloWorld": "Hello World!"
}{
"helloWorld": "Hallo Welt!"
}a csv file
key;en;de;
helloWorld;Hello World!;Hallo Welt!;
is generated.
Note that the column headers en, de are automatically inferred from json basename.
Firstly, add the package as a dev dependency:
dev_dependencies:
json_to_csv:
git:
url: https://github.com/defuncart/json_to_csvSettings can either be defined as command line arguments or in pubspec.yaml.
| Setting | Description |
|---|---|
| files_path | A path to folder containing json files. |
| main_file | A path to folder containing main json file (i.e. en.json). |
| output_file | A path to save the generated csv file. |
| csv_delimiter | A delimiter to separate columns in the input CSV file. Defaults to ;. |
dart run json_to_csv --files_path="assets/json/" --main_file="assets/json/en.json" --output_file="assets/test.csv" --csv_delimiter=";"json_to_csv:
files_path: 'assets/json/'
main_file: 'assets/json/en.json'
output_file: 'assets/test.csv'
csv_delimiter: ';'Ensure that your current working directory is the project root, then run the following command:
dart run json_to_csvThe package can be global activated and used as a cli tool as follows:
dart pub global activate -sgit https://github.com/defuncart/json_to_csv
json_to_csv --files_path="assets/json/" --main_file="assets/json/en.json" --output_file="assets/test.csv" --csv_delimiter=";"The package can be deactivated as follows:
dart pub global deactivate json_to_csvSpotted any issues? Please open an issue on GitHub! Would like to contribute a new feature? Fork the repo and submit a PR!