简体   繁体   中英

How to read a .csv file with more than one language in R?

I want to read a.csv file in R.

However, the.csv file contains words (specific letters) from many languages. For example, german, polish, and greek.

Some rows of the.csv file are the following:

1 Zürich
2 Östra Mellansverige
3 Åland
4 Stredné Slovensko
5 Małopolskie
6 Ελλάδα

The first 4 rows are readable using:

Sys.setlocale(category = "LC_ALL", locale = "german")

The 5th row is readable using:

Sys.setlocale(category = "LC_ALL", locale = "polish")

However, the last row is not readable using:

Sys.setlocale(category = "LC_ALL", locale = "greek")

How can I read all the 6 rows containing all the necessary languages?

Noting that I use the following in order to read the.csv file:

read.csv("file_name.csv",header=TRUE,sep=";",na.strings = "",encoding="UTF-8")

The language of the text does not matter when it comes to loading the data using read.csv . There is no semantics or grammar here, just the encoding of the individual characters. UTF-8 contains characters and symbols from almost all languages around the world, so you can always use it if the file was written with UTF-8 encoding in the first place. Function Sys.setlocale is mostly for formatting decimal points vs commas or to set time zones.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM