[R] Converting CSV file to UTF-8 encoding

Rasmus Liland jr@| @end|ng |rom po@teo@no
Tue May 5 12:56:57 CEST 2020


On 2020-05-05 15:12 +0430, Mehdi Dadkhah wrote:
> I have a CSV file which its encoding is 
> ANSI. How can i change its encoding to 
> UTF-8 in R?

Hi!

I do not know about ANSI, but to read latin1 
encoded csv files into readr, do this:

Determine that your file is latin1-encoded:

	rasmus using twentyfive ~ % file -i SAA.csv
	SAA.csv: application/csv; charset=iso-8859-1

read it in using readr::read_csv

	locale <- readr::locale(encoding = "latin1")
	SAA <- suppressMessages(
	  readr::read_csv(file="SAA.csv",
	                  locale=locale))

Best,
Rasmus



More information about the R-help mailing list