在R中读取CSV文件时出错 [英] Error while reading csv file in R

查看:652
本文介绍了在R中读取CSV文件时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用R读取csv文件时遇到一些问题.

I am having some problems in reading a csv file with R.

 x=read.csv("LorenzoFerrone.csv",header=T)

Error in make.names(col.names, unique = TRUE) : 
      invalid multibyte string at '<ff><fe>N'

我可以使用libre office毫无问题地读取文件.

I can read the file using libre office with no problems.

我无法上传该文件,因为它包含了明智的信息.

I can not upload the file because it is full of sensible information.

我该怎么办?

设置编码似乎可以解决问题.

Setting encoding seem like the solution to the problem.

> x=read.csv("LorenzoFerrone.csv",fileEncoding = "UCS-2LE")
> x[2,1]
[1] Adriano Caruso
100 Levels:  Ada Adriano Caruso adriano diaz Adriano Diaz alberto ferrone Alexey ... Zia Tina

推荐答案

您需要在sep参数中指定正确的定界符.

You need to specify the correct delimiter in the sep argument.

这篇关于在R中读取CSV文件时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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