I can read data as a list of baskets rather than a data frame from an url like this:
url <- "http://www.salemmarafi.com/wp-content/uploads/2014/03/groceries.csv"
baskets <- strsplit(readLines(url), ",", fixed=TRUE)
> head(baskets,2)
[[1]]
[1] "citrus fruit" "semi-finished bread" "margarine" "ready soups"
[[2]]
[1] "tropical fruit" "yogurt" "coffee"
But when I try to accomplish the same by loading data from a file the result is:
baskets2 <- strsplit(readLines("groceries.csv"), ",", fixed=TRUE)
> head(baskets2,2)
[[1]]
[1] "citrus fruit;semi-finished bread;margarine;ready soups;;;;;;;;;;;;;;;;;;;;;;;;;;;;"
[[2]]
[1] "tropical fruit;yogurt;coffee;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"
And with ";" it's:
> baskets2 <- strsplit(readLines("groceries.csv"), ";", fixed=TRUE)
> head(baskets2,2)
[[1]]
[1] "citrus fruit" "semi-finished bread" "margarine" "ready soups"
[5] "" "" "" ""
[9] "" "" "" ""
etc
How could I get the data to load similarly from a file on my computer (ie C:/mypath/groceries.csv) as it is loading from an url ie without the empty items ";;;;"?
*EDIT: This is only one csv and I'm trying to avoid loading it into a data frame.