R – Error Message – “… appears to contain embedded nulls”

Background

Ran into a little error message in R.

 

Error Message

Error Snippet

Here is the error message:

line # appears to contain embedded nulls

Error Body


 bibleBooks = read.table("BibleBook.txt", header=TRUE)
Warning messages:
1: In read.table("BibleBook.txt", header = TRUE) :
  line 1 <span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>appears to contain embedded nulls<span id="mce_SELREST_end" style="overflow:hidden;line-height:0;"></span>
2: In read.table("BibleBook.txt", header = TRUE) :
  line 2 appears to contain embedded nulls
3: In read.table("BibleBook.txt", header = TRUE) :
  line 3 appears to contain embedded nulls
4: In read.table("BibleBook.txt", header = TRUE) :
  line 4 appears to contain embedded nulls
5: In read.table("BibleBook.txt", header = TRUE) :
  line 5 appears to contain embedded nulls
6: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  :
  embedded null(s) found in input

Troubleshooting

Look at the file being imported and saw that yes it has delimiters, line-breaks for each row, but did not have column separators.

Remediation

Outline

  1. Decide on a column delimiter
    • In our case most of our columns are numeric
    • We only have one column, book name, and it does not have semi colon in it
    • And, so we are OK having semi-colon (;)
  2. BCP
    • Issued BCP with semi-colon
      • Syntax -t
  3. R
    • read-table
      • Issue read-table and specify sep argument
        • sep
          • In our case sep=”;”

 

Text Files

bibleBookHeader.txt

BookID;BookName;NumberofChapters;NumberofVersesInLastChapter;VerseIDStart;VerseIDEnd;Testament

Command File

ExportData.cmd

setlocal

set "_server=localhost"
set "_fieldTerminator=;"

bcp  "select * from  bible..BibleBook"  queryout  bibleBookRaw.txt -S %_server% -T -t %_fieldTerminator% -c 

copy bibleBookHeader.txt + bibleBookRaw.txt bibleBook.txt

endlocal

R Console

Command


bibleBooks = read.table("BibleBook.txt", sep=";", header=TRUE)

bibleBooks

Console

RConsole_20180620_0707AM

References

  1. Statistical tools for high-throughput data analysis ( STHDA )
    • Reading Data From TXT|CSV Files: R Base Functions
      Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s