Embedded Nulls when importing CSV into R

#1
Hey there.

I try to import a csv file generated with the phonetics software Praat into R.

When I first did this, there were no problems.

Now everytime I try, strange things happen and I have no clue what's going on, thus I registered here.

I get warnings:

1: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 1 appears to contain embedded nulls
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 2 appears to contain embedded nulls
3: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 3 appears to contain embedded nulls
4: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 4 appears to contain embedded nulls
5: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 5 appears to contain embedded nulls
6: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
embedded nul(s) found in input


And the csv which normally looks like

tmin,tier,text,tmax

10.004477,DF,pr,10.293390
10.293390,DF,rp,10.746967
11.688138,DF,pr,12.072410
...and so on..


looks like that in R:

þÿ
1 NA
2 NA
3 NA
4 NA
5 NA
6 NA
7 NA
...so continuing...
198 NA


Can anyone help me solve this?
 
#3
Now that you mention it, i DID use read.csv. I did not notice before that the warnings mention read table. Which makes it more confusing actually...
 

Dason

Ambassador to the humans
#4
read.csv just calls read.table internally so the warnings make sense. Seeing your code would help though.
 

shmz

New Member
#5
Hi,

I am experiencing exactly the same problem while trying to load flatfiles into Stata or R. I was just wondering whether or not you ever solved the issue and how you went about it?

Many thanks for any help.

S
 
#6
R has a data.entry() function. I use that all the time instead of csv. I used to do it with csv but those nulls are invisible characters. create a vector using c(), open the csv in RStudio, copy the values and paste. Then, delete the hidden nulls taking care not to tamper with the data.
I used to do those tedious tasks before I discovered data.entry().
If you must create a table with copy and paste, create several variables with c() and merge them in a data.frame() table.; though copy and paste is not advisable. use data.entry()
tnx
 
Last edited:
#7
R has a data.entry() function. I use that all the time instead of csv. I used to do it with csv but those nulls are invisible characters. create a vector using c(), open the csv in RStudio, copy the values and paste. Then, delete the hidden nulls taking care not to tamper with the data.
I used to do those tedious tasks before I discovered data.entry().
If you must create a table with copy and paste, create several variables with c() and merge them in a data.frame() table.; though copy and paste is not advisable. use data.entry()
tnx
That doesn't sound very useful when you want to create a function to read hundreds of csv files. If you only have one file to deal with you might as well format it as you like in Excel or similar then import into R to perform statistical procedures.