【发布时间】:2019-03-26 12:58:38
【问题描述】:
我正在尝试读取 1500 个 csv 文件,但出现以下错误。
read.table 中的错误(文件 = 文件,标题 = 标题,sep = sep,quote = quote,: 不允许重复的“row.names”
代码:
fi<-list.files("C:/Users/Desktop/DL/odi_csv_male",full.names=T)
dat<-lapply(fi,read.csv)
但是当单独打开并保存文件时,我可以读取文件。但是由于有 1500 个文件,我需要手动完成。任何帮助将不胜感激?
The file contains version 1.3.0
info team Ireland
info team England
info gender male
info season 2006
info date 6/13/2006
info venue Civil Service Cricket Club, Stormont
info city Belfast
info toss_winner England
info toss_decision bat
info player_of_match ME Trescothick
info umpire R Dill
info umpire DB Hair
info match_referee CH Lloyd
info winner England
info winner_runs 38
ball 1 0.1 England ME Trescothick EC Joyce DT Johnston 0 0
ball 1 0.2 England ME Trescothick EC Joyce DT Johnston 0 0
ball 1 0.3 England ME Trescothick EC Joyce DT Johnston 0 4
【问题讨论】:
-
您的某个文件可能格式错误。
lapply(fi, function(f){print(f);read.csv(f)})将在读取每个文件名时将其打印出来。在问题文件中打印的最后一个文件 -
如何解决?
-
试试
lapply(fi, read.csv, row.names = NULL)。 -
它给出错误文件(文件,“rt”)中的错误:无法打开连接另外:警告消息:在文件(文件,“rt”)中:无法打开文件'1000887.csv' : 没有这样的文件或目录
-
如果我打开每个文件并将其保存为 csv 然后我就可以阅读它。它很耗时
标签: r