gpt4 book ai didi

r - 在 read.table() : incomplete final line found by readTableHeader

转载 作者:行者123 更新时间:2023-12-03 12:46:34 25 4
gpt4 key购买 nike

当我尝试 read.csv() 时,我有一个 CSV该文件,我收到警告警告消息:

In read.table(file = file, header = header, sep = sep, quote = quote,  :
incomplete final line found by readTableHeader on ...

尽管在 StackOverflow 和 R-help 中寻找解决方案,但我无法隔离问题。

这是数据的 Dropbox 链接: https://www.dropbox.com/s/h0fp0hmnjaca9ff/PING%20CONCOURS%20DONNES.csv

最佳答案

这不是 CSV 文件,每一行是一列,您可以手动解析它,例如:

file <- '~/Downloads/PING CONCOURS DONNES.csv'
lines <- readLines(file)
columns <- strsplit(lines, ';')
headers <- sapply(columns, '[[', 1)
data <- lapply(columns, '[', -1)
df <- do.call(cbind, data)
colnames(df) <- headers
print(head(df))

请注意,您可以忽略警告,因为缺少最后一个行尾。

关于r - 在 read.table() : incomplete final line found by readTableHeader,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22171858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com