JSON and CSV Processing
May 30, 2026 | 5 min read
JSON Transformation
import json
def transform_records(data: str) -> str:
records = json.loads(data)
out = []
for r in records:
out.append({
'id': r['id'],
'total': r['price'] * r['quantity']
})
return json.dumps(out)
CSV Processing
def sum_column(rows: list[list[str]], col: int) -> float:
total = 0.0
for row in rows[1:]:
total += float(row[col])
return total
Large Files
Stream large files line-by-line and compile the per-line transformation function with Pyvorin.