简体   繁体   English

无法将 csv 编码为 UTF-8

[英]Unable to encode csv to UTF-8

I am importing a csv and want to encode it to UTF-8 as some columns appear like this:我正在导入 csv 并希望将其编码为 UTF-8,因为某些列如下所示:

Comentario                                                                     Fecha      Mes   `Estaci\xf3n` Hotel        Marca
  <chr>                                                                          <date>     <chr> <chr>         <chr>        <chr>
1 "No todas las instalaciones del hotel se pudieron usar, estaban cerradas sin ~ 2020-02-01 feb.  "Invierno"    Sol Arona T~ Sol  
2 "Me he ido con un buen sabor de boca, y ganas de volver. Me ha sorprendido to~ 2019-11-01 nov.  "Oto\xf1o"    Sol Arona T~ Sol  
3 "Hotel normalito. Est\xe1 un poco viejo. Las habitaciones no tienen aire acon~ 2019-09-01 sep.  "Verano"      Sol Arona T~ Sol 

I have tried the following:我尝试了以下方法:

df<- read.csv("SolArona.csv",  sep=",", encoding = "UTF-8")

But this returns Error in read_csv("SolArona.csv", sep = ",", encoding = "UTF-8"): unused arguments (sep = ",", encoding = "UTF-8").但这会在 read_csv("SolArona.csv", sep = ",", encoding = "UTF-8") 中返回错误:未使用的 arguments (sep = ",", encoding = "UTF-8")。 So, I have also tried doing the Encoding of each column:所以,我也尝试过对每一列进行编码:

df <-read_csv("SolArona.csv")
Encoding(df$Comentario)<-"UTF-8"
Encoding (df$Estaci\xf3n)<-"UTF-8"

Thanks very much in advance!首先十分感谢!

Try this, insert another encoding if nescessary试试这个,如果需要,插入另一个编码

library(readr)
df<- read_csv("SolArona.csv",",",locale = locale(encoding = "UTF-8"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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