Skip to content

feat: add CSV output format - #13

Merged
MudassarTariq merged 1 commit into
mainfrom
feat/csv-output
Nov 5, 2026
Merged

MudassarTariq merged 1 commit into
mainfrom
feat/csv-output

Conversation

@DaudAhmadJF

Copy link
Copy Markdown
Member

Add --output csv to every command, alongside pretty, raw, table and yaml.

A top-level JSON array becomes one row per record, which is what the bulk endpoints return; any other response becomes a single row. Nested objects flatten into dotted column names such as location.city. An array of scalars joins into one cell with |, while an array of objects keeps a column per element so its fields stay addressable. Columns are the sorted union of the keys of every row, so the same response always produces the same file.

Numbers are read with json.Decoder.UseNumber and written exactly as the API sent them. Decoding into float64 would render current_time_unix as 1.772535675329e+09 and round long identifiers.

Values are guarded against spreadsheet formula injection, since organization names and whois text come from third parties. A leading =, @, tab or carriage return is quoted off, as is a + or - followed by a non-digit. Signed data is left intact, so the -122.08421 longitude, the +1 calling code, the +1.00H and -1.00H DST durations and the lone - the astronomy endpoint uses for an absent sun or moon status all survive unchanged.

On the bulk commands --output-file now follows --output: csv saves a .csv file, every other format keeps saving the .json it always has. The extension is appended only when the given name lacks it, so --output-file results and --output-file results.csv both write results.csv. This also fixes --output-file=output.json, which previously wrote output.json.json.

Add `--output csv` to every command, alongside pretty, raw, table and yaml.

A top-level JSON array becomes one row per record, which is what the bulk
endpoints return; any other response becomes a single row. Nested objects
flatten into dotted column names such as `location.city`. An array of scalars
joins into one cell with `|`, while an array of objects keeps a column per
element so its fields stay addressable. Columns are the sorted union of the
keys of every row, so the same response always produces the same file.

Numbers are read with json.Decoder.UseNumber and written exactly as the API
sent them. Decoding into float64 would render `current_time_unix` as
1.772535675329e+09 and round long identifiers.

Values are guarded against spreadsheet formula injection, since organization
names and whois text come from third parties. A leading `=`, `@`, tab or
carriage return is quoted off, as is a `+` or `-` followed by a non-digit.
Signed data is left intact, so the `-122.08421` longitude, the `+1` calling
code, the `+1.00H` and `-1.00H` DST durations and the lone `-` the astronomy
endpoint uses for an absent sun or moon status all survive unchanged.

On the bulk commands `--output-file` now follows `--output`: csv saves a .csv
file, every other format keeps saving the .json it always has. The extension
is appended only when the given name lacks it, so `--output-file results` and
`--output-file results.csv` both write results.csv. This also fixes
`--output-file=output.json`, which previously wrote output.json.json.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@MudassarTariq
MudassarTariq merged commit 85a45b2 into main Nov 5, 2026
5 checks passed
@MudassarTariq
MudassarTariq deleted the feat/csv-output branch November 5, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants