Csv2json
Python scripts to convert between CSV and JSON using Pandas
Install / Use
/learn @nephridium/Csv2jsonREADME
usage: json2csv.py [-h] [-S SEPARATOR] [-i] [-I INDEXLABEL]
[-u USECOLS [USECOLS ...]] [-n NAMES [NAMES ...]]
[-a APPEND [APPEND ...]] [-p]
[infile] [outfile]
Converts a JSON file to CSV
positional arguments:
infile Input file name, default: data.json
outfile Output file name, default: [infile_basename].csv
optional arguments:
-h, --help show this help message and exit
-S SEPARATOR, --separator SEPARATOR
CSV separator used, default ","
-i, --index Write row names (index)
-I INDEXLABEL, --indexlabel INDEXLABEL
Label for index column
-u USECOLS [USECOLS ...], --usecols USECOLS [USECOLS ...]
List of names of columns to use
-n NAMES [NAMES ...], --names NAMES [NAMES ...]
Column names to use
-a APPEND [APPEND ...], --append APPEND [APPEND ...]
Names of columns to append
-p, --printdata Print formatted data when done
To avoid ambiguity put the list following flags -u, -n, and -a into quotes.
Alternatively, supply infile (and optional outfile) before listing the flags.
usage: csv2json.py [-h] [-S SEPARATOR] [-H HEADERLINE] [-c COLUMNS]
[-u USECOLS [USECOLS ...]] [-n NAMES [NAMES ...]]
[-N NROWS] [-s SKIPROWS] [-r USEROWS [USEROWS ...]]
[-a APPEND [APPEND ...]] [-p]
[infile] [outfile]
Converts a CSV file to JSON
positional arguments:
infile Input file name, default: data.csv
outfile Output file name, default: [infile_basename].json
optional arguments:
-h, --help show this help message and exit
-S SEPARATOR, --separator SEPARATOR
CSV separator used, default ","
-H HEADERLINE, --headerline HEADERLINE
Header line to use as column names
-c COLUMNS, --columns COLUMNS
Number of columns to crop to
-u USECOLS [USECOLS ...], --usecols USECOLS [USECOLS ...]
List of names of columns to use
-n NAMES [NAMES ...], --names NAMES [NAMES ...]
Column names to use
-N NROWS, --nrows NROWS
Number of rows to read
-s SKIPROWS, --skiprows SKIPROWS
Number of rows to skip before reading
-r USEROWS [USEROWS ...], --userows USEROWS [USEROWS ...]
List of rows to use
-a APPEND [APPEND ...], --append APPEND [APPEND ...]
Names of columns to append
-p, --printdata Print formatted data when done
To avoid ambiguity put the list following flags -u, -n, -r and -a into quotes.
Alternatively, supply infile (and optional outfile) before listing the flags.
Related Skills
node-connect
349.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
109.8kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
349.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
349.9kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
