使用UTF-16LE编码读取csv的快速方法 [英] Fast method to read csv with UTF-16LE encoding

查看:413
本文介绍了使用UTF-16LE编码读取csv的快速方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理采用UTF-16LE编码的.csv文件,该方法可以读取文件,但是与read_csv相比,read.csv的速度非常慢.

I'm dealing with .csv files with UTF-16LE encoding, this method works to read the files, but read.csv is very slow compared to read_csv.

  read.csv2(path,dec=",",skip=1,header=T,fileEncoding="UTF-16LE",sep="/t")

不幸的是,我无法使read_csv工作,我只得到空行,甚至找不到在该函数中指定编码的方法.

Unfortunately I can't make read_csv work, I only get empty rows and I don't find a way to even specify encoding in the function.

我无法共享我的数据,但是如果有人处理此编码,将不胜感激.

I can't share my data, but if anyone dealt with this encoding any help would be appreciated.

推荐答案

您可以使用具有语言环境选项locale=locale(encoding="UTF-16LE")的read_csv之类的阅读器功能来指定文件编码.但是,我尚未使用read_csv成功读取utf-16le文件.我收到不完整的多字节序列"错误.有一个相关的已提交问题,但我的文件仍然存在问题-希望其他人将会有更多的成功.

You can specify file encodings with readr functions like read_csv with the locale option: locale=locale(encoding="UTF-16LE"). However, I haven't successfully read in a utf-16le file with read_csv. I get an "Incomplete multibyte sequence" error. There's a related issue filed, but I still have issues with my file -- hopefully others will have more success.

这篇关于使用UTF-16LE编码读取csv的快速方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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