top | item 28672762

(no title)

claimred | 4 years ago

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

discuss

order

hnlmorg|4 years ago

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"]

slaymaker1907|4 years ago

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.

IncRnd|4 years ago

So does linux and such:

  cat data.csv | sed 's/,/ ,/g' | column -t -s, | less -S