简体   繁体   中英

Reading in .csv file to R. Error in Scan

Reading in a .csv file, but got the following error:

Books <- read.table(file.choose(),header=TRUE,sep=";")
Error in scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings,  : 
line 21688 did not have 3 elements

.csv file name BX-Book-Ratings.csv

Original - 1 column and 1048576 rows

Shown - 1 column and 10 rows

User-ID;"ISBN";"Book-Rating"        
276725;"034545104X";"0"     
276726;"0155061224";"5"     
276727;"0446520802";"0"     
276729;"052165615X";"3"     
276729;"0521795028";"6"     
276733;"2080674722";"0"     
276736;"3257224281";"8"     
276737;"0600570967";"6"     
276744;"038550120X";"7"

Area with the error - rows 21687:21694

4376;"0345378490";"0"
4376;"38208715X";"5"
4377;"\\"0210000010";"8"
4385;"0061042331";"0"
4385;"0061083402";"10"
4385;"0061083577";"0"
4385;"0061093343";"9"
4385;"0061096156";"10"

Please let me know if I can provide additional information. Thank you.

I do not have sufficient reputation points to add this as a comment above. Are you certain you counted correctly in pasting rows 21687:21694? The error was supposed to be in line 21688, but the line below has mismatched quotes... Data cleaning is a major step in such analyses.

4377;"\\"0210000010";"8"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM