0

I run the following:

data <- read.csv("C:/Users/user/Desktop/directory/file.csv")

These are my warning messages:

Warning messages:
1: In read.table("C:/Users/user/Desktop/directory/file.csv",  :
  line 1 appears to contain embedded nulls
2: In read.table("C:/Users/user/Desktop/directory/file.csv",  :
  line 2 appears to contain embedded nulls

          ....

6: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  :
  embedded nul(s) found in input

The resulting data frame is just a column filled with NAs.

A problem might be that all my data is in one column separated by commas like this(first row is header, second row is example data):

stat_breed,tran_disp,train_key,t_type,trainer_Id,horsedata_Id
QH,"Tavares Joe","214801","E",0,0

What can I do to accurately read my data?

Jaap
  • 81,064
  • 34
  • 182
  • 193
jgozal
  • 1,480
  • 6
  • 22
  • 43
  • 1
    You can try adding `skipNul = T` to your read.csv call and see if that reads your data in properly – C_Z_ Oct 29 '15 at 16:30
  • thank you @CactusWoman. I think skipNul= T and sep = "," did the job – jgozal Oct 29 '15 at 16:34
  • would you mind explaining me what was happening? – jgozal Oct 29 '15 at 16:35
  • 1
    There seems to be an issue with whatever is producing the data. You should track that down and fix it, ideally, rather than accepting faulty input in R. – Konrad Rudolph Oct 29 '15 at 16:44
  • 1
    See this [similar question](http://stackoverflow.com/questions/23209464/get-embedded-nuls-found-in-input-when-reading-a-csv-using-read-cv) for a discussion of the issue. – Ken Benoit Oct 29 '15 at 16:48
  • thank you @KonradRudolph. Do you think there might be risks if I use skipNul = T? If so what risks? Unfortunately I don't have too much control on what is generating the data – jgozal Oct 29 '15 at 17:01
  • 1
    @jgozal `skipNul=T` itself probably only carries minimal risks. But you’re receiving garbled data, so the process generating the data is clearly buggy. That should be a huge warning sign. — Do you know that you can actually trust the data? – Konrad Rudolph Oct 29 '15 at 17:12

0 Answers0