-
Notifications
You must be signed in to change notification settings - Fork 607
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
Feature Request: csvlook to wrap long columns #389
Comments
I vote for this too. If possible I would suggest to add 2 options:
Original Output:
Column1 Truncated at 10 Output:
Original Output:
Column1 text Wrapped at 10 Output:
Regards |
Needed wrapping mode today, so I came up with this implementation. Let me know how to improve it so that it can be included. |
themirugo: works as requested thanks. An improvement would be to be able to set wrap length per column. We have now a perl script that does that: EDIT: (unfortunately there is no support for fixed width so it doesn't look good pasting the result here) With the above features one can format the output table to be nice and readable without being too wide for some screens. |
@mkauzlar That wouldn't be hard to implement that in csvlook. However specifying the charwidth for each columns seems overkill for most of the situations and complicates the CLI. From what I've understood csvlook is not meant to be the ultimate csv viewer but just a "good enough" for most use cases. Providing a max width for all the columns seems a good trade off between ease of use and functionality. Let's hear @onyxfish's opinion on this, perhaps he can provide a good solution. |
I'm not even sure that |
Needed this again today. I'll send a PR. |
+1 for the ability to set a max width to truncate a column at |
It would be very useful just to have a setting to set a max width for each column, so that a single wide value doesn't make the whole file unreadable. |
Setting a single max value for all the columns seems a good trade off between having a complicated CLI and being able to quickly view datasets with long fields. By the way, I don't think this PR will be processed quickly / at all. The project seems to have a backlog of PRs dating back to a year ago. |
I created pull request #482 to fix this |
The implementation of this functionality is moving out of the csvkit repository into its new dependency agate (#515). This is the file that would need to be modified. I've opened an issue there referring to all issues and PRs related to this feature request. |
Re-opening as this can now be implemented thanks to the issue I opened on agate being fixed. |
The agate commits just introduced truncation, not wrapping. |
@themiurgo I apologize for your pull request not getting due attention back when it was fresh. As you noticed this project has been on ice for a while as the backend was being reimplemented as agate. That being the case, I would merge a wrapping pull request for agate (eg. The one caveat I have is this seems like a fairly unusual case and I don't want it at the cost of making the implementation tremendously complicated. If there is a way to implement it that's straightforward then great. |
Ah, sorry, I had reopened this based on the issue title ("truncate") not the description ("wrapping"). Re-closing as before. |
I'll re-open a new issue just for truncating: #561 |
Hey folks, I'm having trouble understanding the resolution of this feature request. The referenced pull requests concern the "agate" dependency, but I can't find any patches which implement the functionality here in csvkit. Neither the csvlook documentation nor the csvkit's changelog mention wrapping, either. Can csvkit format output so that individual cells are displayed across multiple lines? |
There's no wrapping, only truncation. To avoid confusion, open a new issue on agate. |
Got it. Here's the issue wireservice/agate#773. Thanks for the quick response! |
Quite often I have csv files that I want to quickly scan, that have one or two columns with very long strings (i.e. >2000 characters). csvlook will then wrap them over many lines.
What I would suggest is to add an argument with which the user can specify a maximum length for each column to display. If, for example, I set this to 50, then for each row, all columns that contain more than 50 characters are truncated.
At first, I thought that the option -z would do exactly that, but apparently it doesn't.
The text was updated successfully, but these errors were encountered: