1
我试图使用aws.s3
库从我的Rstudio会话中从AWS S3读取。我正在关注this instructions。下面的几行通过cloudyr/aws.s3库从Rstudio从AWS S3读取TXT文件'm️
obj <-get_object("s3://my_bucket/myfile.csv")
csvcharobj <- rawToChar(obj)
con <- textConnection(csvcharobj)
data <- read.csv(file = con)
只是正常读取csv
文件。但是下面的替代方法会返回txt
文件的错误。
obj <-get_object("s3://my_bucket/myfile.txt")
csvcharobj <- rawToChar(obj)
con <- textConnection(csvcharobj)
data <- read.table(file = con)
Error in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
line 1 did not have 6 elements
对此问题的任何建议解决方案?谢谢。
是您的文本文件表格格式,我的意思是说,read.table需要数据以表格格式,如csv https://stat.ethz.ch/R-manual/R-devel/library/utils /html/read.table.html –