Skip to content

json2csv.py is a Python script that converts JSON data to CSV format. It dynamically lists keys from the JSON file, allows users to select which keys to include, and offers an option to escape HTML characters. Ideal for transforming JSON data into a more readable and analyzable CSV format for various applications.

License

Notifications You must be signed in to change notification settings

Pb-22/json2csv.py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

json2csv

json2csv is a Python script that converts JSON data into CSV format. This script is designed to handle various JSON structures and allows users to select specific keys to include in the CSV output. Additionally, it provides an option to escape characters that may be interpreted as HTML, ensuring compatibility with systems that process HTML content.

Features

  • Dynamic Key Selection: Automatically extracts keys from the JSON data and prompts the user to select which keys to include in the CSV.
  • HTML Character Escaping: Optionally escape characters that may be interpreted as HTML to ensure data integrity.
  • Progress Tracking: displays a progress bar while converting JSON to CSV.
  • Flexible Input Handling: Supports both JSON arrays and JSON objects containing a data key.

Usage

  1. Clone the Repository:

    git clone https://github.com/Pb-22/json2csv.py.git
    cd 
  2. Run the Script:

    python json2csv.py <json_file>

    Replace <json_file> with the path to your JSON file.

  3. Follow the Prompts:

    • The script will display available keys and prompt you to select which keys to include in the CSV.
    • You can type all to include all keys.
    • The script will also ask if you want to escape characters that may be interpreted as HTML. The default choice is Y (Yes).

Example

python json2csv.py data.json

Output:

Available keys:
1. key1
2. key2
3. key3
Enter the numbers of the keys you want to include, separated by commas, or type 'all' to include all keys: all
Would you like to escape characters that may be interpreted as HTML? (Y/n): Y
Opening JSON file...
Loading JSON data...
JSON data loaded, processing 100 items...
Converting JSON to CSV: 100%|███████████████████████████████████████████████████████████

About

json2csv.py is a Python script that converts JSON data to CSV format. It dynamically lists keys from the JSON file, allows users to select which keys to include, and offers an option to escape HTML characters. Ideal for transforming JSON data into a more readable and analyzable CSV format for various applications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages