On 16 January 2023, Max wrote:
> Does anyone know a tool or hack to help fix a problem at a CSV that's
> causing a "The rows are not all the same number of columns." error when
> trying to import the CSV at a web application?
At a shell, this could help narrow things down:
$ cat foo.csv
$ while read line; do echo $line | tr -dc "," | wc -m; done < foo.csv
There's no counter to show you which line has the strange number of commas, but
you could do this after you've eyeballed it and seen most have two:
$ while read line; do echo $line | tr -dc "," | wc -m; done < foo.csv > counts.csv
$ grep -v 2 -c counts.csv
This ignores "quoted,commas,in,one,column" but if there aren't too many of them
they won't get much in the way.
Librarian, artist and licensed private investigator.
CO₂: 419.29 ppm (Mauna Loa Observatory, 2023-01-15)