CSV ↔ JSON
CSV、TSV、セミコロン区切りのデータを JSON に変換し、また CSV に戻します。クォートされたフィールドやヘッダーの有無を扱い、ファイルとして保存できます。
ブラウザ内だけで動作します。入力した内容はどこにもアップロードされません。
[
{
"id": "1",
"customer": "Ryu, Min",
"email": "ryu@example.com",
"total": "49.90",
"currency": "USD"
},
{
"id": "2",
"customer": "Ada \"the countess\" Lovelace",
"email": "ada@example.com",
"total": "120.00",
"currency": "GBP"
},
{
"id": "3",
"customer": "Grace Hopper",
"email": "grace@example.com",
"total": "15.50",
"currency": "USD"
}
]RFC 4180 に従います。クォートされた区切り文字、二重にしたクォート、フィールド内の改行がそのまま保たれます。
CSV・JSON リファレンス
クイックリファレンス- "クォート, フィールド"
- 区切り文字やクォート、改行を含むフィールドは二重引用符で囲む必要があります。
- フィールド内の ""
- RFC 4180 で唯一のエスケープ方法です。Ada ""the countess"" Lovelace は Ada "the countess" Lovelace として読み戻されます。
- 区切り文字
- 既定はカンマですが、小数点にカンマを使う地域ではタブ(TSV)やセミコロンが優先されます。
- ヘッダー行
- ヘッダーがあると各行が列名をキーにしたオブジェクトになり、ない場合は配列のままです。
- CRLF と LF
- RFC 4180 は CRLF ですが、多くのパーサーは LF も受け付けます。Excel は CRLF と末尾の改行を付けます。
- Excel の CSV
- 列をあらかじめテキスト書式にしないと、Excel は先頭の 0 を落とし長い数値を書き換えます。制御したい場合はデータ → テキストからインポートを使います。
Python の関連文法ガイド
Python のガイドをすべて見るPython iter(): How the Built-in Function Works
Explains Python's iter() built-in: how it creates iterators, the two-argument sentinel form, custom iterator classes, and common edge cases.
PythonPython Pika: Queues, Exchanges, Routing Keys, and Acknowledgements
Learn how to use Python's Pika client with RabbitMQ: declare queues and exchanges, publish with routing keys, consume messages, and handle acknowledgements reliably.
PythonPython Kafka: kafka-python vs Confluent Client
python kafka python vs confluent kafka: Compare kafka-python and Confluent Kafka Python clients: API differences, performance, feature coverage, and when to choose eac...
PythonPython Kafka Offsets, Partitions, and Manual Commits
Learn how Kafka offsets and partitions work and how to manually commit offsets in Python consumers with kafka-python and confluent-kafka. Covers sync vs async commits, rebalances, and seeking.