LIVE · 1258 online · 6 new posts today · Free Friday soon

Good morning, builder 👋

25,000 builders share prompts, tools & wins daily — free forever.

🟢 1258 online now·3,357 24hrs online·25,978 members·25,342 posts·📱 22,007 app downloads·✨ newest: matteo41🃏 Cards🎓 Academy🗃 Vault💰 Treasury🎬 Theater🎁 Freebies🩻 SEO X-Ray
Create an account

New here? Join Data-Forums — ask questions, share builds & trade smarter with us.Sign up freeLog in×

Thread

How do I convert CSV to JSON in Python (and back)?

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
60 total views  ·  71 guest views

#1
Three ways, from quickest to most control:

1. pandas
Code:
import pandas as pd df = pd.read_csv('data.csv') df.to_json('data.json', orient='records')

2. csv + json modules (no dependencies)
Code:
import csv, json with open('data.csv') as f: rows = list(csv.DictReader(f)) with open('data.json', 'w') as f: json.dump(rows, f, indent=2)

3. DF Toolbox – for quick one-off conversions the CSV ⇄ JSON converter on tools.php does both directions instantly, no code needed.

Watch out for: encoding (use encoding='utf-8'), and numbers stored as strings (convert them explicitly).

How do you handle the CSV → JSON step in your pipelines – code, tooling, or both?
👍 Like0❤️ Love0😂 Haha0🔥 Fire0👏 Clap0⚡ 0
Reply

Users browsing this thread:
1 Guest(s)

Forum Jump:
Join AI builders shipping real tools. No hype, no guru courses — just post-mortems, prompts, and people who build.

The community for AI engineers, automation builders, prompt crafters, cybersecurity folks & data practitioners. Talk about what ships — not what trends.

26.2k+
Posts
25.6k
Threads
25978+
Members
1271
Online
⏱️ 1 min read
Share