Live data from Hacker News

Show HN: Tidy Viewer – a cross-platform CSV pretty printer for viewer enjoyment

github.com

71–80 of 141 posts

Re: Show HN: Tidy Viewer – a cross-platform CSV pretty printer for viewer enjoyment

#71
Wanted to mention that Windows PowerShell supports pretty CSV printing out of the box, like so

  Import-Csv .\Levels.csv | Format-Table

  Count Level elevation Level name Name              Object type Unique ID
  ----- --------------- ---------- ----              ----------- ---------
  1     -600.0000000    Store      -0,600 - Store    Level       dc611fed-1783-d759-053a-b19848c51491
  1     2850.0000000    Store      +2,850 - Store    Level       c59f2ae4-0e94-6ea0-bd82-8306971e628c
  1     3350.0000000    Roof       +3,350 - Roof     Level       7b487ac2-e102-dc23-6ad9-81c39124de1d

Re: Show HN: Tidy Viewer – a cross-platform CSV pretty printer for viewer enjoyment

#72
post #58

Earlier quoted context omitted.

thank you! I knew some of that but learned a lot too.

Google the phrase "useless use of cat". To some, it's a faux-pas. Personally, I like the aesthetics of cat for my own scripts. It follows the "pipe flowing" idiom better. There are performance reasons why "useless cat" should be avoided though. So avoid it where performance is important (or when some other hardcore CLI jockey is going to see your code :))

I understand that people say you can replace

    foo 
with

    
but I've never been able to get myself to do this.

Re: Show HN: Tidy Viewer – a cross-platform CSV pretty printer for viewer enjoyment

#73

Wanted to mention that Windows PowerShell supports pretty CSV printing out of the box, like so Import-Csv .\Levels.csv | Format-Table Count Level elevation Level name Name Object type Unique ID ----- --------------- ---------- ---- ----------- --------- 1 -600.0000000 Store -0,600 - Store Level dc611fed-1783-d759-053a-b19848c51491 1 2850.0000000 Store +2,850 - Store Level c59f2ae4-0e94-6ea0-bd82-8306971e628c 1 3350.0…

PowerShell is actually pretty good at manipulating CSV and JSON. However, I would definitely recommend using v7 (i.e. pwsh) since it has many improvements over v5 (default on Windows). For example, Group-Object seems to be several orders of magnitude faster using the latest version.

Re: Show HN: Tidy Viewer – a cross-platform CSV pretty printer for viewer enjoyment

#74

I spend a lot of time in the terminal and want to quickly glance at a csv files without making a new script, opening excel, or using a tui. I made tidy-viewer (tv) because current tools like cat and column were not pretty enough. tv modifies raw files in the following ways: 1. NA detection and highlighting 2. Printing only significant digits 3. Header and footer meta data I have been using this a lot at work. There i…

First of all - kudos on tackling this task - it is indeed very annoying to get CSVs to render nicely on a terminal. 1. How does tidy-viewer compare with csvlook? 2. Looking at the demo video, there seems to be an odd fixation with "N/A". The CSV spec, AFAIK, doesn't recognize this phrase. I don't understand why someone would expect a quoted string field whose raw characters are "n/a" should be rendered as anything ot…

First of all - kudos on tackling this task - it is indeed very annoying to get CSVs to render nicely on a terminal.

> How does tidy-viewer compare with csvlook?

The most important issue to me is that csvlook is a much less pleasant viewing experience, but there is also this ...csvlook reads and parses all of the data. Try pushing diamonds.csv to csvlook. When I do it on my machine it takes 15.228 seconds while tv takes 0.0042 seconds. For this reason tv is much faster, but speed is not the goal of the package. tv's purpose is to maximize viewer enjoyment.

2. Looking at the demo video, there seems to be an odd fixation with "N/A". The CSV spec, AFAIK, doesn't recognize this phrase. I don't understand why someone would expect a quoted string field whose raw characters are "n/a" should be rendered as anything other than n/a (i.e. lowercase and without the quotes). I'm guessing maybe in your workflow you want to use that phrase a lot, but for a tool for the general public I'd not do this kind of interpretation; and I would leave an empty field as empty.

I could not say it better than this:

> The norm of treating missing data as NA exists in R (which the developer of this is clearly inspired by based on the GitHub readme.). Pandas in Python is stuck with NaN for numeric types (not quite correct) and "" or None for string types. Personally I like the choice to both explicitly render missing data in colour and to apply NA as a placeholder text to display that colour.

3. tidy-viewer seems to require "unstable library features", or at least ones which were unstable as of Rust 1.48.0 . It would be nice if you could be compatible with older rust distributions/versions.

That is a good point. I also release binaries which I think makes this requirement less needed. What are your thoughts.

4. Many systems, especially older ones, especially ones which you access remotely and don't have root privileges on, won't have a rust installation. It would be even more convenient if you could provide binaries with little or no extra dynamic library dependencies, which could be used on older / rustless systems. I realize this is a tall order, however.

With github actions I auto-build binaries for many OSes. See https://github.com/alexhallam/tv/releases/tag/0.0.13

5. What about scrolling? The worst part of viewing CSVs is having to handle wide ones which exceed the terminal width, and having decent horizontal as well as vertical scrolling ability. less doesn't cut it, because it doesn't keep the header row, plus it doesn't recognize field widths.

Scrolling is nice. To offer scrolling the only option I am aware of is turning this cli into a tui. I made the choice early on to stay chose the more minimal path and stick to a cli. The goal is to be a `column` replacement not a spreadsheet replacement.

6. tidy-viewer does not seem to support wrapping longer fields onto multiple terminal lines.

The goal is to glance at the data as a whole not a cell or fields. If there are cells with long text they get cut at 20 characters. I like this a lot. I would prefer to know that there is a lot of text that I can dig into latter, but when I am glancing at the csv I just want an overall picture. In my view tables of data are data visualizations meaning that I don't have to show everything to understand enough of it.

7. When the user doesn't specify the color scheme, are you choosing one based on the terminal colors, or are you using absolute color values? I suggest the former.

Great question. I want to eventually add the ability for users to make a config file will their own colors. At this time I just have absolute presets. If you are interested I would happily take a contribution that allows users the option to configure tv with some dotfile.

8. tidy-viewer loads and parses the entire CSV immediately; and, in fact, seems to keep two copies of it in memory at once. This means it cannot be used with large files without thrashing; and even if your CSV does fit in global memory, it will still be kind of unusable, trying to dump gigabytes onto the terminal.

That is almost true. tidy-viewer reads the entire csv, but only parses the head. If I knew of a way to get the number of rows and columns of a csv without reading the whole file then I would. I know there is a good deal more room for memory optimization. This is not my strength and I am still learning.

9. Bottom line: A nice initial effort, but the more serious challenges are yet to be tackled, plus needs to be more robustly cross-platform.

Thanks for the compliment. It is still a work in progress.

Re: Show HN: Tidy Viewer – a cross-platform CSV pretty printer for viewer enjoyment

#75

Wanted to mention that Windows PowerShell supports pretty CSV printing out of the box, like so Import-Csv .\Levels.csv | Format-Table Count Level elevation Level name Name Object type Unique ID ----- --------------- ---------- ---- ----------- --------- 1 -600.0000000 Store -0,600 - Store Level dc611fed-1783-d759-053a-b19848c51491 1 2850.0000000 Store +2,850 - Store Level c59f2ae4-0e94-6ea0-bd82-8306971e628c 1 3350.0…

There's also ConsoleGridView.

https://devblogs.microsoft.com/powershell/introducing-consol...

Re: Show HN: Tidy Viewer – a cross-platform CSV pretty printer for viewer enjoyment

#76

Wanted to mention that Windows PowerShell supports pretty CSV printing out of the box, like so Import-Csv .\Levels.csv | Format-Table Count Level elevation Level name Name Object type Unique ID ----- --------------- ---------- ---- ----------- --------- 1 -600.0000000 Store -0,600 - Store Level dc611fed-1783-d759-053a-b19848c51491 1 2850.0000000 Store +2,850 - Store Level c59f2ae4-0e94-6ea0-bd82-8306971e628c 1 3350.0…

Shameless plug, but so does my shell, https://github.com/lmorg/murex

  $ open test/example.csv | format generic
  Login email         Identifier  One-time password  Recovery code  First name  Last name  Department   Location
  rachel@example.com  9012        12se74             rb9012         Rachel      Booker     Sales        Manchester
  laura@example.com   2070        04ap67             lg2070         Laura       Grey       Depot        London
  craig@example.com   4081        30no86             cj4081         Craig       Johnson    Depot        London
  mary@example.com    9346        14ju73             mj9346         Mary        Jenkins    Engineering  Manchester
  jamie@example.com   5079        09ja61             js5079         Jamie       Smith      Engineering  Manchester
My shell also aims to have closer compatibility with POSIX (albeit it's not a POSIX shell) so you can use all the same command line tools you're already familiar with too (which, for me at least, was the biggest hurdle in my adoption of PowerShell).

It also supports other file types out of the box too. eg jsonlines

  $ open test/example.csv | format jsonl
  ["Login email","Identifier","One-time password","Recovery code","First name","Last name","Department","Location"]
  ["rachel@example.com","9012","12se74","rb9012","Rachel","Booker","Sales","Manchester"]
  ["laura@example.com","2070","04ap67","lg2070","Laura","Grey","Depot","London"]
  ["craig@example.com","4081","30no86","cj4081","Craig","Johnson","Depot","London"]
  ["mary@example.com","9346","14ju73","mj9346","Mary","Jenkins","Engineering","Manchester"]
  ["jamie@example.com","5079","09ja61","js5079","Jamie","Smith","Engineering","Manchester"]

Re: Show HN: Tidy Viewer – a cross-platform CSV pretty printer for viewer enjoyment

#77

Earlier quoted context omitted.

Well, I think being promiscuous with "NA", "N/A", nan, etc. is a separate issue from a blank cell. A blank cell is literally missing. That should be filled with NA.

> A blank cell is literally missing. That should be filled with NA. Why? "NA" stands for "Not Applicable", but a blank cell in a CSV could represent any number of things of which "Not Applicable" is only one.

haha. You are right "NA" stands for "Not Applicable". That is not always how people/programs using it though. What are some alternatives that you would suggest? I am happy to learn.

Re: Show HN: Tidy Viewer – a cross-platform CSV pretty printer for viewer enjoyment

#78
post #30

Earlier quoted context omitted.

Same. Read this as some profound observation on what TVs actually are. Even thought to myself "huh, I guess OP does has a point..."

> "huh, I guess OP does has a point..." LMAO, me too! Guess I've been spending too much time thinking. Edit: this reminds me of Jimmy Kimmel's segment where they "bleep and blur whether they need it or not" so that innocent TV clips appear to have profanity/innuendo etc.

LMAO. I wish.

Re: Show HN: Tidy Viewer – a cross-platform CSV pretty printer for viewer enjoyment

#80

Earlier quoted context omitted.

> A blank cell is literally missing. That should be filled with NA. Why? "NA" stands for "Not Applicable", but a blank cell in a CSV could represent any number of things of which "Not Applicable" is only one.

haha. You are right "NA" stands for "Not Applicable". That is not always how people/programs using it though. What are some alternatives that you would suggest? I am happy to learn.

I would suggest similar to what other people have suggested where you color the background of the cell red and then just display the literal content of the cell. I think it would be reasonable to have this configurable via command line arguments though, so if you like the "NA" that could also be a mode.

Perhaps it would make sense to have a "pretty" mode and a "literal" mode (which would also turn off the clever processing of numbers)?

Post reply on HN