读取txt文件时遇到的问题(带引号的字符串中的EOF) [英] Problems with reading a txt file (EOF within quoted string)

查看:494
本文介绍了读取txt文件时遇到的问题(带引号的字符串中的EOF)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用 read.table()导入 R (包含由WMO提供的有关气象台站的信息)=nofollow> TXT ):

然而,当我尝试使用

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

我得到这个错误

 在引用字符串中的eof 

警告,并且只有3514条6702行显示在 tmp 中。从这个文本文件快速浏览,我找不到任何看似有问题的字符。



正如其他线程中所建议的,我也试过引用= EOF 警告消失了,但仍然只导入了3514行。



有关如何获得 read.table()为这个特定的txt文件工作吗?

解决方案

看起来像你的数据实际上有11548行。这样做:

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

编辑:根据下面的MrFlick的评论进行更新。


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?

解决方案

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.

这篇关于读取txt文件时遇到的问题(带引号的字符串中的EOF)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆