1

I am using a windows based machine. I have a test.txt document that has encoding as 'ANSI' having Swedish Characters inside. I hope I can read the information to R for further analyses. any suggestion?

the current solution I have is I need to save as the .txt document as new document having 'utf_8' encoding then use the code below.But would love to have a suggestion can read the 'ANSI' in right formate directly. Thank you!

the document looks like: enter image description here

the document format: enter image description here

the code works if i re save the .txt to 'utf-8' format

dftxt <- readr::read_delim('./data/text_Briljant2.txt', 
                       delim = '\t', skip = 15,
                       locale = locale('se', encoding = 'UTF-8'),
                       col_names = F) %>% select(-c(X5, X6))

seems it is not feasible to provide a reproducible sample. but if you let me know where I can upload the file I would love to provide.

Thank you for any suggestions.

CloverCeline
  • 511
  • 3
  • 18

1 Answers1

0
dftxt <- readr::read_delim('test.txt', 
                           delim = '\t', skip = 15,
                           locale = locale('se', encoding = 'ISO8859-1'),
                           col_names = F) %>%
  select(-c(X5, X6))
CloverCeline
  • 511
  • 3
  • 18