Repository navigation
feat: add CSV output format - #13
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
--output csvto 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_unixas 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.08421longitude, the+1calling code, the+1.00Hand-1.00HDST durations and the lone-the astronomy endpoint uses for an absent sun or moon status all survive unchanged.On the bulk commands
--output-filenow 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 resultsand--output-file results.csvboth write results.csv. This also fixes--output-file=output.json, which previously wrote output.json.json.