Python Prompts Free Prompt

Python Script to Convert CSV to JSON and Vice Versa

Write a Python script to convert CSV files to JSON and JSON to CSV
☆ Save
Prompt
You are a Python automation expert. Write a script that converts between CSV and JSON formats. The script must: 1) Accept input and output file paths as arguments, 2) Support both CSV-to-JSON and JSON-to-CSV conversions, 3) Handle large files efficiently (streaming), 4) Preserve data types (strings, numbers, booleans), 5) Handle nested JSON structures appropriately for CSV (flatten), 6) Provide options for delimiter, encoding, and pretty-printing, 7) Include error handling for malformed files. Add unit tests and a README.

How to use this prompt

1
Click Copy Prompt above to copy to your clipboard.
2
Open ChatGPT, Claude, Gemini, or any AI assistant and paste the prompt.
3
Replace any [PLACEHOLDER] values with your specific details.
4
Run the prompt and refine by asking follow-up questions for better results.