Skip to content
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

cli: improve the csv/tsv output (and sql results in general) #18584

Closed
knz opened this issue Sep 19, 2017 · 3 comments
Closed

cli: improve the csv/tsv output (and sql results in general) #18584

knz opened this issue Sep 19, 2017 · 3 comments
Assignees

Comments

@knz
Copy link
Contributor

knz commented Sep 19, 2017

Previously the csv/tsv output would output the total row count at the beginning, now it does at the end.

@bdarnell suggests: having the row count at the end makes parsing difficult. Do we really need it?

Initially I thought that the row count was useful at least for humans so that a csv/tsv output on the screen can be easily sized (humans are not good at counting manually). So Ben suggested we only display the row count when interactive, which is indeed a simple change.

However after thinking this some more I realized that we have another need: when a client issues multiple queries one after another, we also need a delimiter to separate result batches. This is especially true for csv/tsv where otherwise there would be no delimiter and no way to distinguish the column header of a new result batch from an extra row in the previous batch.

That said, the row count is not a very good delimiter either -- it is a variable string and thus difficult to match.

So instead I propose to do the following:

  • make the row count only appear on interactive shells by default (perhaps with an option to hide/show it)
  • add two new options "footer" and "header", with footer set to "--" by default, to be printed before and after result batches

@bdarnell would this be adequate?

@knz knz self-assigned this Sep 19, 2017
@knz
Copy link
Contributor Author

knz commented Sep 19, 2017

(psql has footer/header too)

@bdarnell
Copy link
Member

The common case is a single query; this should not print a header/footer/delimiter by default. I think a delimiter (printed in between results) makes more sense than a header/footer (printed with every result), but I'd be OK with a header/footer as long as it's only used when there are multiple queries (or maybe if the footer is a blank line - something that CSV parsers won't choke on)

@knz
Copy link
Contributor Author

knz commented Sep 19, 2017

I like the blank line the best. It is visually unintrusive while being extremely reliable (you can't have a blank line as part of a field without quotes). I will do that and avoid the feature bloat altogether.

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

No branches or pull requests

2 participants