读取txt文件时出现问题(带引号的字符串中的EOF)(Problems with reading a txt file (EOF within quoted string))

编程入门 行业动态 更新时间:2024-10-24 04:36:50
读取txt文件时出现问题(带引号的字符串中的EOF)(Problems with reading a txt file (EOF within quoted string))

我正在尝试使用read.table() 将此TXT文件导入到R (包含由WMO提供的有关气象站的信息):

但是,当我尝试使用

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

我得到这个错误

eof within quoted string

' tmp '中只有6702条线条中的3514条出现。 从快速查看文本文件,我找不到任何看似有问题的字符。

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

有关如何让read.table()为这个特定的txt文件工作的任何建议?

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?

最满意答案

它看起来像你的数据实际上有11548行。 这工作:

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

编辑:根据@ MrFlick的评论如下更新。

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.

更多推荐

本文发布于:2023-07-26 00:14:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1268331.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:引号   字符串   文件   EOF   txt

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!