I have a CSV file the first row of which contains the variables names and the rest of the rows contains the data. What's a good way to break it up into files each containing just one variable in R? Is this solution going to be robust? E.g. what if the input file is 100G in size?
The input files looks like
var1,var2,var3
1,2,hello
2,5,yay
...
I want to create 3 (or however many variables) files var1.csv, var2.csv, var3.csv so that files resemble File1
var1
1
2
...
File2
var2?
2
5
...
File3
var3
hello
yay
I got a solution in Python (http://stackoverflow.com/questions/3331608/how-to-break-a-large-csv-data-file-into-individual-data-files) but I wonder if R can do the same thing? Essential the Python code reads the csv file line by line and then writes the lines out one at a time. Can R do the same? The command read.csv reads the whole file all at once and this can slow the whole process down. Plus it can't read a 100G file and process it as R attempts to read the whole file into memory. I can't find a command in R that let's you read a csv file line by line. Please help. Thanks!!