Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export a csv in utf-8 format?

Tags:

I am trying to export a data.frame to a csv with utf-8 encoding. I have tried generating the file with write.csv with no success and the help(write.csv) did not mention any specific advice on creating that specific output. Here is my current export line.

write.csv(prod_out, file="product_output.csv",append=FALSE,eol="\r") 

Any advice you can offer is appreciated.

like image 517
analyticsPierce Avatar asked Sep 25 '10 06:09

analyticsPierce


People also ask

How do I convert a CSV file to UTF-8 in Excel 2016?

Go to File and then Save as. At the bottom of the window you will find a dropdown list called Encoding, there select UTF-8 and press Save.

How do I know if my CSV is UTF-8?

The evaluated encoding of the open file will display on the bottom bar, far right side. The encodings supported can be seen by going to Settings -> Preferences -> New Document/Default Directory and looking in the drop down.


2 Answers

This question is pretty old - I guess things have changed a lot since 2010. Anyway, I just came across this post and I happen to know the solution. You just add fileEncoding = "UTF-8" option directly to write.csv.

like image 68
Michal J Figurski Avatar answered Oct 03 '22 22:10

Michal J Figurski


Try opening a UTF8 connection:

con<-file('filename',encoding="UTF-8") write.csv(...,file=con,...) 
like image 45
mbq Avatar answered Oct 04 '22 00:10

mbq