hello William,
> #old:
> rule TOP {<line>* %% \n }
> token line { <col>* %% ',' }
> #new:
> rule TOP {<line>* }
> token line { <col>* %% ',' \n }
ohhh ... indeed! when i fixed the code on Ralph's instructions, i
finally was able to slurp a whole file and discovered a emtpy entry at
the end of the flow so i realize that \n is actually a terminator, not
a separator.
> class CSV_as_table {
> method TOP ($/) { make $/<line>.map: *.made }
> method line ($/) { make $/<col>.map: *.made }
> method col:sym<bare> ($/) { make ~$/ }
> #method col:sym<quoted> ($_) { .make: ~S:g/'""'/"/ }
> method col:sym<quoted> ($/) { make $/.subst(/'""'/, '"', :global) }
> }
nice :)
but as i said earlier, i really prefer the short one.
> been interesting nevertheless. Here's a related link to a one-liner that
> uses Raku's Text::CSV module:
> https://unix.stackexchange.com/a/670358/227738
This grammar really was an exercice. I also wrote a really simple csv2tsv
in C which is really fast and was actually simpler to write.
regards,
marc