Importing a CSV with different row widths into Incanter?

517 Views Asked by At

I'm trying to import a CSV file with rows of many different lengths into Incanter using the read-dataset function. Unfortunately, it appears to truncate the rows down to the length of the first row. Short of reordering the dataset, or searching for the largest row and adding a row at the top of that width, is there a way to solve this problem? The documentation doesn't seem to offer any optional parameters to read-dataset.

1

There are 1 best solutions below

0
On

Some CSV passers expect the first line in a CSV to be column headings. If these columns have a fixed meaning you can try and add meaningful headings and see what Incanter does with this.

If you don't have meaningful column names one solution would be to find out the most columns either possible or supplied in this file then add either an row of arbitrary headers or a row of empty strings with the maximum number of entries.