在R中嵌入nul中的fread错误:'\0' [英] Error with fread in R--embedded nul in string: '\0'
问题描述
我尝试读取一个csv文件> 4GB,但是,当我使用 fread
命令时会产生错误
I am trying to read a csv file >4GB, However, when I use fread
command it produces and error
library(data.table)
csv1 <- fread("cleaned.csv",sep = ",",colClasses = "character",showProgress = TRUE)
错误: \0'
Error: embedded nul in string: '\0'
经过一番查找后,我发现你可以使用 sed
,例如在此 stackoverflow问题但是我不知道如何在我的场景中使用它。请帮助!
After some looking I found that you could use sed
function
such as in this stackoverflow Question But I have no clue how to use it in my scenario. Please help!
更新:
我试图使用sed函数,如下所述,错误。
UPDATE: I have attempted to use the sed function as described below in comments, however, they throw an error.
sed无法冲洗stdout设备上没有剩余空间
UPDATE2:
我已经在一些同事的帮助下解决了。但是,我仍然希望自动化这个活动,因为我不得不重复每个文件的过程。预期自动化将来自R或使用BASH脚本。任何建议?
UPDATE2: I have solved it with the help of some colleagues.However, I am still looking to automate this activity since I had to repeat the process for each file. Expected Automation would either be from within the R or using a BASH Script. Any Suggestions?
推荐答案
csv文件用 ^ @ 填充,值,无论如何不能通过 sed命令
搜索或替换,以解决问题,我遵循以下解决方案。
The csv files were populated with ^@ and they were placed within the blank values, somehow they couldn't be searched or replaced via sed commands
to solve the problem, I followed the following solution.
在linux中,按照文件目录,使用vim命令,如
In linux, follow to the file directory and use vim command such as,
vim filename.csv
:%s / CTRL + 2 // g
ESC #TO从插入模式切换
:wq# FILE
我必须手动为每个文件。但是,我仍然在寻找一种方法来自动化在R或使用从BASH脚本。
I had to do this manually for every file. However, I still looking for a way to automate this either within R or using from BASH script.
这篇关于在R中嵌入nul中的fread错误:'\0'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!