Re:Working with CSV files on shell/terminal
by LispSporks22 on Wednesday June 28, 2023 @11:42AM
(#36508127)
Ruby's CSV module can be handy:
I like the seen example the dude has:
[ Parent
| on HN ]
Re:Working with CSV files on shell/terminal
by mr_o47 on Wednesday June 28, 2023 @12:14PM
(#36508605)
I didn’t know you could do that in ruby but its pretty cool
Re:Working with CSV files on shell/terminal
by afefers on Wednesday June 28, 2023 @01:03PM
(#36509308)
As someone who's new to programming and doesn't know Ruby at all, can you (or someone) please explain how it works, what it does, and how would someone use it?
I find it beautiful, tho :)
Re:Working with CSV files on shell/terminal
by LispSporks22 on Wednesday June 28, 2023 @01:33PM
(#36509759)
-rcvs
Load the (built-in) CSV module in Ruby. -e
Eval the following string as Ruby code. CSV($<)
Create CSV parser with standard input `$<` as the source. .each
Run the code in the block that follows for each row (automatically skips the CSV header): { |r| puts r[0] }
For a row, print the first/0th element. Can be simplified in recent Ruby: { puts _1[0] }