Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Importing a CSV with different row widths into Incanter?

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.

like image 313
Michael Curry Avatar asked May 03 '11 23:05

Michael Curry


People also ask

How do I import only certain columns from a CSV file into R?

Method 1: Using read. table() function. In this method of only importing the selected columns of the CSV file data, the user needs to call the read. table() function, which is an in-built function of R programming language, and then passes the selected column in its arguments to import particular columns from the data.

How rows are separated in CSV?

A CSV file contains a number of rows, each containing a number of columns, usually separated by commas.

Do CSV files have row limits?

csv files have a limit of 32,767 characters per cell. Excel has a limit of 1,048,576 rows and 16,384 columns per sheet. CSV files can hold many more rows.


1 Answers

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.

like image 183
David Waters Avatar answered Oct 16 '22 17:10

David Waters