Dear R useRs, I have big (23000 rows), vertical bar delimited file: e.g. A00001|Text a,Text b, Text c|345 A00002|Text bla|456 ... .. . Try using A <- read.table('filename.txt', header=FALSE,sep='\|') process stop at line 11975 with warning message: number of items read is not a multiple of the number of columns I have no problems with processing similar file, which is only 10000 rows long? Any suggestion what's the problem here. Thank's in advance. Cheers, Andrej
Andrej Kastrin <andrej.kastrin at siol.net> writes:> Dear R useRs, > > I have big (23000 rows), vertical bar delimited file: > > e.g. > A00001|Text a,Text b, Text c|345 > A00002|Text bla|456 > ... > .. > . > > Try using > > A <- read.table('filename.txt', header=FALSE,sep='\|') > > process stop at line 11975 with warning message: > number of items read is not a multiple of the number of columns > > I have no problems with processing similar file, which is only 10000 > rows long? > > Any suggestion what's the problem here. Thank's in advance.Well, the most obvious suspect is the file... You might try table(count.fields('filename.txt',sep='|')) (There's no point in escaping the vertical bar) Also, beware of quote symbols in the file, and possibly consider using fill=TRUE. -- O__ ---- Peter Dalgaard ??ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
Hello, Well... the error message is explicit enough: "number of items read is not a multiple of the number of columns" means that you do not have the right number of items around line 11975 (not the same number as in the 11974 previous lines)! This is an error in you file. Best, Philippe Grosjean Andrej Kastrin wrote:> Dear R useRs, > > I have big (23000 rows), vertical bar delimited file: > > e.g. > A00001|Text a,Text b, Text c|345 > A00002|Text bla|456 > ... > .. > . > > Try using > > A <- read.table('filename.txt', header=FALSE,sep='\|') > > process stop at line 11975 with warning message: > number of items read is not a multiple of the number of columns > > I have no problems with processing similar file, which is only 10000 > rows long? > > Any suggestion what's the problem here. Thank's in advance. > > Cheers, Andrej > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >
By the way, you might find this sed one-liner useful: sed -n '11981q;11970,11980p' filename.txt It will print the offending line and its neighbors. If you're on Windows you need to install Windows Services For Unix or Cygwin.> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Andrej Kastrin > Sent: Wednesday, January 25, 2006 3:08 AM > To: r-help > Subject: [R] read.table problem > > Dear R useRs, > > I have big (23000 rows), vertical bar delimited file: > > e.g. > A00001|Text a,Text b, Text c|345 > A00002|Text bla|456 > ... > .. > . > > Try using > > A <- read.table('filename.txt', header=FALSE,sep='\|') > > process stop at line 11975 with warning message: > number of items read is not a multiple of the number of columns > > I have no problems with processing similar file, which is only 10000 > rows long? > > Any suggestion what's the problem here. Thank's in advance. > > Cheers, Andrej > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html >