-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CSV output option #279
Conversation
Hey @mikejoh thanks for the PR! At first glance this looks great, thanks for adding tests. We'll take a closer look asap. |
pkg/api/output.go
Outdated
var row []string | ||
for _, k := range columnIndexes { | ||
if columns[k].value(o) == "" { | ||
row = append(row, "n/a") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be uncalled for when thinking about it, during testing I noticed that I got an extra trailing ,
in the end of rows (last column) where there are no data (empty string
). I then added something to replace that with, in this case a n/a
, to fill in the blanks basically.
I don't think that the trailing ,
is a problem but adding n/a
might be something users won't expect since there are no other output options that add this to the output of data. This would also add a n/a
at any place where there is an empty string
.
WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right that a trailing comma is normal in a csv file and in fact ok if there are empty columns with a few commas in a row having nothing between them. We can remove that n/a
as you suggest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Fixed in: 64edde6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing my review for the n/a
change is made to the output.
This PR fixes #278
Checklist
Description
What's the goal of this PR?
The goal of this PR is to add another output option via the
--output
flag to be able to output CSV formatted data.What changes did you make?
I added an extra output option called
csv
which will, if used, output data tostdout
in CSV format.What alternative solution should we consider, if any?
N/A