r - read.table cut off a long row into half. how to reorganize the cvs file -
c <- read.table("sid-110-20130826t164704.csv", sep = ',', fill=true, )
so use above code read 300 csv files. , files this
65792,1,round-5,72797,140,yellow,75397,192,red,75497,194,crash 86267,1,round6,92767,130,yellow,94702,168,brake,95457,178,go,95807,185,red,96057,190,brake,97307,200,crash 108092,1,round-7,116157,130,yellow,117907,165,red 120108,1,round-8,130173,130,yellow,130772,142,brake,133173,152,red 137027,1,round-9,147097,130,yellow,148197,152,brake,148597,160,red
as can see second longer other line (for each row third element supposed have round#) , when read.table r cuts line in half, below copied first 5 columns r
9 86267 1 round-6 92767 130 10 95807 185 red 96057 190 11 108092 1 round-7 116157 130 12 120108 1 round-8 130173 130
is there way edit row 1 line instead of being split?
you can prime data.frame width specifying "col.names" argument along "fill=true" in:
c <- read.table("sid-110-20130826t164704.csv", sep = ',', fill=true, col.names=paste("v", 1:21,sep=""))
that's assuming know how many columns have. if don't know, might want make single pass through file find maximum width.
Comments
Post a Comment