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

print_table should handle embedded newlines #749

Open
sethk opened this issue Nov 6, 2020 · 3 comments
Open

print_table should handle embedded newlines #749

sethk opened this issue Nov 6, 2020 · 3 comments
Labels

Comments

@sethk
Copy link

sethk commented Nov 6, 2020

So, some CSVs have newlines embedded inside quoted strings. They are parsed correctly, but totally mangle the output of print_table. It seems there are two options for dealing with this:

  1. Render the newlines as literal \n text, or more nicely as one of ⏎, ␤, ␍, ␊, etc.
  2. Potentially generate multiple lines of output per row, with horizontal dividers between each row. This could be done only after embedded newlines were encountered.

I've decided to take a stab at #2, which works ideally for my purposes. It probably needs more options, like the maximum number of lines per row, or whether to use a different divider (e.g. =) to separate the header from the rest of the rows. I'll open a pull request for my quick and dirty version in case anybody is interested in pursuing this.

sethk added a commit to sethk/agate that referenced this issue Nov 6, 2020
@jpmckinney
Copy link
Member

PR: #750

@jpmckinney
Copy link
Member

Not sure what people prefer in terms of options (1) or (2), so leaving PR open for more input.

@jpmckinney
Copy link
Member

Having tested it again, I think the dividers are maybe not desirable. For example, in files with very few problematic newlines, those dividers will significantly increase the size of the output, and worsen readability.

So, option (1) is preferred.

Test data:

a,b,c
1,2,3
"Once upon
a time",5,6
1,2,3
1,2,3
1,2,3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants