Read.CSV Warning 'Eof Within Quoted String' Prevents Complete Reading of File

read.csv warning 'EOF within quoted string' prevents complete reading of file

You need to disable quoting.

cit <- read.csv("citations.CSV", quote = "", 
row.names = NULL,
stringsAsFactors = FALSE)

str(cit)
## 'data.frame': 112543 obs. of 13 variables:
## $ row.names : chr "10.2307/675394" "10.2307/30007362" "10.2307/4254931" "10.2307/20537934" ...
## $ id : chr "10.2307/675394\t" "10.2307/30007362\t" "10.2307/4254931\t" "10.2307/20537934\t" ...
## $ doi : chr "Archaeological Inference and Inductive Confirmation\t" "Sound and Sense in Cath Almaine\t" "Oak Galls Preserved by the Eruption of Mount Vesuvius in A.D. 79_ and Their Probable Use\t" "The Arts Four Thousand Years Ago\t" ...
## $ title : chr "Bruce D. Smith\t" "Tomás Ó Cathasaigh\t" "Hiram G. Larew\t" "\t" ...
## $ author : chr "American Anthropologist\t" "Ériu\t" "Economic Botany\t" "The Illustrated Magazine of Art\t" ...
## $ journaltitle : chr "79\t" "54\t" "41\t" "1\t" ...
## $ volume : chr "3\t" "\t" "1\t" "3\t" ...
## $ issue : chr "1977-09-01T00:00:00Z\t" "2004-01-01T00:00:00Z\t" "1987-01-01T00:00:00Z\t" "1853-01-01T00:00:00Z\t" ...
## $ pubdate : chr "pp. 598-617\t" "pp. 41-47\t" "pp. 33-40\t" "pp. 171-172\t" ...
## $ pagerange : chr "American Anthropological Association\tWiley\t" "Royal Irish Academy\t" "New York Botanical Garden Press\tSpringer\t" "\t" ...
## $ publisher : chr "fla\t" "fla\t" "fla\t" "fla\t" ...
## $ type : logi NA NA NA NA NA NA ...
## $ reviewed.work: logi NA NA NA NA NA NA ...

I think is because of this kind of lines (check "Thorn" and "Minus")

 readLines("citations.CSV")[82]
[1] "10.2307/3642839,10.2307/3642839\t,\"Thorn\" and \"Minus\" in Hieroglyphic Luvian Orthography\t,H. Craig Melchert\t,Anatolian Studies\t,38\t,\t,1988-01-01T00:00:00Z\t,pp. 29-42\t,British Institute at Ankara\t,fla\t,\t,"

Problems loading .csv file into RStudio. EOF within quoted string

Here you go:

require(tidyverse)
df <- readr::read_csv("Chicago_Crimes_2005_to_2007.csv")

You may decide to clean up the column names as some have spaces in them, if so:

colnames(df) <- c("rowNo",
"ID",
"Case.Number",
"Date",
"Block",
"IUCR",
"Primary.Type",
"Description",
"Location.Description",
"Arrest",
"Domestic",
"Beat",
"District",
"Ward",
"Community.Area",
"FBI.Code",
"X.Coordinate",
"Y.Coordinate",
"Year",
"Updated.On",
"Latitude",
"Longitude",
"Location")

EOF within quoted string warning when merging csv files

It is possible that same columns in different files are read as different types when some of them have some 'character' element and some are just numeric. Here, is one method to read with all columns specified as "character" column, rbind the elements and then use type.convert to automatically convert the column classes based on the value it have

library(data.table)
out <- rbindlist(lapply(list.files(path=myfolder, full.names = TRUE),
fread, colClasses = "character"))
out <- type.convert(out, as.is = TRUE)

Problems with reading a txt file (EOF within quoted string)

It looks like your data actually has 11548 rows. This works:

read.table(url('http://weather.noaa.gov/data/nsd_bbsss.txt'), 
sep=';', quote=NULL, comment='', header=FALSE)

edit: updated according @MrFlick's comment's below.



Related Topics



Leave a reply



Submit