0

I have an Excel file with some text. I have saved it as CSV file and read into R using readr::read_csv2(). But I cannot figure out how to get rid of the weird characters below:

[131] "W<U+008A>rmflasche <e3>Hug<d2>\r \r"                                             
[132] "Held f<U+009F>r einen Tag <d0> Aufblasbare Superhelden-Ausr<U+009F>stung \r"     
[133] "Metallic Tattoos & Haarkrone <d0> Fashion Set\r"                             

I tried to use iconv but I have no clue in which encoding the files was saved in the first place.

EDIT: I am adding the first lines of the csv file:

name;product_details
Geschenkset Cupcake Dekoration ;"Erh�ltlich in vier Varianten: Cupcake Geschenkset � Weihnachtsglitzer"
D Pinto
  • 871
  • 9
  • 27
  • can you show the iconv line? and also part of what's inside csv file which has this kind of data – Hardik Gupta Nov 25 '16 at 10:06
  • do you think that could be a problem of my machine? I just found out that when printing out put from a tibble I get weird characters as well, e.g. "A tibble: 325 2" – D Pinto Nov 25 '16 at 10:08
  • what's the encoding set in file -> reopen with encoding, set to utf-8 and try – Hardik Gupta Nov 25 '16 at 10:10
  • paste some part of csv as well, it will be helpful – Hardik Gupta Nov 25 '16 at 10:10
  • that didn't work; this line I got from the console: "A tibble: 325 2". Would it be the case that R as whole is using a different encoding? I am using a MacBook Pro 2016 with macOS Sierra – D Pinto Nov 25 '16 at 10:17
  • is the unicode character encoding for multiplacation symbol http://www.fileformat.info/info/unicode/char/00d7/index.htm – Hardik Gupta Nov 25 '16 at 10:28
  • yes, but do you have any idea why the console is displaying instead of the multiplication symbol itself? – D Pinto Nov 25 '16 at 10:33

2 Answers2

0

Try reading your file like this

readLines("filepath", encoding="UTF-8")
Hardik Gupta
  • 4,700
  • 9
  • 41
  • 83
0

It turns out that I had the same problem described in this question Set locale to system default UTF-8. The most voted answered solved my problem as well.

Community
  • 1
  • 1
D Pinto
  • 871
  • 9
  • 27