警告消息:行似乎包含嵌入的空值 [英] Warning message: line appears to contain embedded nulls

查看:44
本文介绍了警告消息:行似乎包含嵌入的空值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试读取 csv 文件列表.这些 csv 文件有;"作为它的分隔符.在读入 csv 文件失败后,我尝试将其中一个 csv 文件中的内容分成几个部分,然后读入每个部分的值以查看问题出在哪里.

I am trying to read in a list of csv files. These csv files have ";" as its separator. After failing to read in the csv files, I have tried to cut the contents in one of the csv files into several parts and read in the values in each part to see where the problem was caused.

这种方法对我有用,而且我找到了一个适用于我的数据的工作代码:

This method worked for me, and I have figured out a working code that works for my data:

y <- data.table(read.table(filenames[i], header = FALSE, sep = ";",
                comment.char = "", fill = TRUE, check.names = FALSE,
                blank.lines.skip = TRUE))

但是我遇到了另一个问题.当我将原始数据复制并粘贴到 csv 文件中并运行代码时,它运行良好.但是,当我尝试在原始 csv 文件上运行相同的代码时,它给了我嵌入式空值"警告.

But I have encountered another problem. When I copy and paste the original data in a csv file and run the code it just works fine. However, when I try to run the same code on the original csv file, it gives me the 'embedded nulls' warning.

从外面看,原来的数据和复制的数据一模一样,都是以csv格式保存的.因此,我很难找到导致警告的确切原因以及我的原始 csv 文件和复制的 csv 文件之间的区别.

On the outside, the original data and the copied data look exactly the same, and they are all saved in the csv format. Therefore, it is hard for me to find what is exactly causing the warning and what is the difference between my original csv file and the copied csv file.

数据如下所示:

Measurement Reports export file;
;
Comment;Time ;E_MW;E_PF;INV11_ACKW;INV12_ACKW;INV21_ACKW;INV22_ACKW;INV31_ACKW;INV32_ACKW;INV41_ACKW;INV42_ACKW;INV51_ACKW;INV52_ACKW;INV61_ACKW;INV62_ACKW;M1_ATEMP;M1_HUMID;M1_PYRA1S;M1_PYRA2S;M1_PYRA3S;M1_WDIREC;M1_WSPEED;
;
;00:00;-0.02  ;-0.36  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;22.32  ;82.32  ;0.00  ;0.00  ;0.00  ;234.83  ;0.00  ;
;00:01;-0.02  ;-0.36  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;0.00  ;22.26  ;82.57  ;0.00  ;0.00  ;0.00  ;214.93  ;0.00  ;
;
;Sum;-1.41    ;-22.10    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;1330.89    ;5098.24    ;0.00    ;0.00    ;0.00    ;11246.06    ;28.48    ;
;Mean;-0.02    ;-0.37    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;0.00    ;22.18    ;84.97    ;0.00    ;0.00    ;0.00    ;187.43    ;0.47    ;
;

任何帮助将不胜感激.谢谢你.

Any help would be appreciated. Thank you.

推荐答案

@G 在评论中发布的解决方案.Grothendieck 是使用 fileEncoding= 参数来指定正确的编码,根据 OP,结果是 UTF16LE 或 UCS-2LE.

The solution, as posted in a comment by @G. Grothendieck, was to use the fileEncoding= argument to specify the correct encoding, which turned out to be either UTF16LE or UCS-2LE according to the OP.

将其写为答案,以免丢失评论.

Writing this as an answer so that is not lost to the comments.

这篇关于警告消息:行似乎包含嵌入的空值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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