Get embedded nul(s) found in input when reading a csv using read.csv()
Your CSV might be encoded in UTF-16. This isn't uncommon when working with some Windows-based tools.
You can try loading a UTF-16 CSV like this:
read.csv("mycsv.csv", ..., fileEncoding="UTF-16LE")
Read.csv() throws error
read.csv
doesn't read XLS(X) files, only CSV files. Try opening your Excel file in Excel, exporting it to CSV and reissuing your read.csv
command (depending on your system language, you might want to use read.csv2
instead).
Issues importing a csv in R
I finally found the solution!
I was going nuts; even my instructor didn't know how to fix it!
This statement works:
o<-read.csv("C:/Users/Admin/Desktop/-=Data Science=-/11-27-2018/Occ.txt", header=T, sep="\t", fileEncoding="UTF-16LE")
Like I said in my original question: I tried using fileEncoding="UTF-16LE" and it didn't help. After asking the question, I tried using sep="\t", and it didn't help. But using both of them did the trick!
Embedded nul in string' error when importing csv with fread
We can remove the null terminators on the command line using something like:
sed 's/\\0//g' mycsv.csv > mycsv.csv
Or as suggested by @marbel, fread allows you to pass the sed call inside the text. Such as:
fread("sed 's/\\0//g' mycsv.csv")
Related Topics
Plot Multiple Lines in One Graph
How to Use Reference Variables by Character String in a Formula
Converting Multiple Columns from Character to Numeric Format in R
Displaying Text Below the Plot Generated by Ggplot2
Replace Na in Column With Value in Adjacent Column
Dummy Variables from a String Variable
Add Correct Century to Dates With Year Provided as "Year Without Century", %Y
How to Calculate Cumulative Sum
Remove Na Values from a Vector
R Shiny Passing Reactive to Selectinput Choices
Control Ggplot2 Legend Look Without Affecting the Plot
How to Divide Each Row of a Matrix by Elements of a Vector in R
Read Multiple CSV Files into Separate Data Frames
Pasting Two Vectors With Combinations of All Vectors' Elements
How to Export Multiple Data.Frame to Multiple Excel Worksheets