Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

fread (data.table in R) with specification of encoding

Could not find proper answer in previous questions and answers to my problem: 1. I have a 2.3 GB csv file which contains 2.4 million rows of Hebrew Text, currently coded in ASCII. Since we are talking about big file, fread would be preferable but what about the encoding? Any idea how to read csv file coded in ASCII to avoid the famous "embedded nul in string" error?

Thank you

like image 985
Dmitry Leykin Avatar asked Apr 29 '15 09:04

Dmitry Leykin


1 Answers

As of August 25th the case linked by David Arenburg is closed, and the functionality is included in the currently available version of data.table. The encoding parameter can now be used when calling fread:

text <- fread(file, encoding = 'UTF-8')

ASCII is not an explicit encoding option, but ASCII is valid UTF-8, so you can specify UTF-8 when you want to read your Hebrew text.

like image 90
Alex A. Avatar answered Oct 26 '22 15:10

Alex A.