7

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.

  • 3
    Could you show the code that you're using, and maybe some snippet of data? Because this is strange - CSV means, "comma-separated value" and shouldn't depend on value's width – Alex Ott May 04 '11 at 06:51
  • I just checked read-dataset on CSV file exported from Excel, where many cells had different length - everything works fine – Alex Ott May 04 '11 at 07:25
  • 4
    Could the OP meant different number of columns? Please clarify question. – Paul Lam Jun 22 '11 at 16:37
  • I used clojure-csv and had very good luck with it. I would be interested in seeing your code. – octopusgrabbus Sep 26 '11 at 18:54
  • I would love to hear back from you with the original request from Alex Ott. I have to do stuff similar to your original question. – octopusgrabbus Oct 26 '11 at 14:29
  • doesn't make sense to me, either. if the columns are comma-delimited, their length shouldn't matter. or, if some rows have more columns than the header row, then what are the names of the additional columns? if your dataset is more like a list of values for a single property on each row (e.g. tag sets), it doesn't really fit the design goals of csv as i know them. – RubyTuesdayDONO Nov 13 '11 at 16:27

1 Answers1

1

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.

David Waters
  • 11,979
  • 7
  • 41
  • 76