Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

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

I am trying to use read.table() to import this TXT file into R (contains informations about meteorological stations provided by the WMO):

However, when I try to use

tmp <- read.table(file=...,sep=";",header=FALSE)

I get this error

eof within quoted string

warning and only 3514 of the 6702 lines appear in 'tmp'. From a quick look at the text file, I couldn't find any seemingly problematic characters.

As suggested in other threads, I also tried quote="". The EOF warning disappeared, but still only 3514 lines are imported.

Any advice on how I can get read.table() to work for this particular txt file?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...