Special Characters in csv-files and stacking those through R

Hi 

I have trouble stacking CSV-files through the R method. At first special characters were wierd signs when importing but after fooling around with encoding and locale the import from each file stops at the first special character. So instead of looping through ~200 lines it loops through ~10. 

Have anybody tried anything similar?

0

Comments

7 comments
  • Hi,

    I did successfully import a CSV-file with read.table(filepath, header = TRUE, dec = ",", sep = ";"). Which code do you use for importing?

    Thanks,

    Carolin

    0
  • Hi Carolin

    Thank you for your response

    I've used:

    dataset <- NULL

    file_list <- list.files('filepath', full.names = TRUE)

    for (file in file_list){
    dataset<-rbind(dataset, read.csv2(file)}

    I suspect I've changed the systems locale thruough a

    sys.setlocale command - but I fail to see why R just stops when it finds a special character...

     

    0
  • Hi Niels

    I've just tested import of a file through the R plugin in Data Discovery with a selection of special characters and danish letters - it seemed to work out fine.

    If you suspect errors in system locales maybe you can compare your current settings with mine - by running the Sys.getlocale() command?
    > Sys.getlocale()
    [1] "LC_COLLATE=Danish_Denmark.1252;LC_CTYPE=Danish_Denmark.1252;LC_MONETARY=Danish_Denmark.1252;LC_NUMERIC=C;LC_TIME=Danish_Denmark.1252"

     

    0
  • Hi Niels

    Maybe I'm missing something - but how do I get responses from R? It's the R on the antserver and the only place (I've found) I can write R-code is in Dataservice - Data sources - Add Data source.

    I do have R on my PC but it is not the same as the R installation on the server, which I don't have access to.

    0
  • And thanks for the help :)

    0
  • It's a good point - if you don't have access to the server, it makes it a little difficult.

    But may I ask - how did you change the locales in the first place then?

    Did you just change them on your own laptop and did that change the behaviour of the R-plugin?

    0
  • Hi Niels

    I actually dont know if I've changed anything - but my import kept turning up with roadsigns for Æ, Ø, Å. I then tried to change encoding and/or locale by putting 'encoding='xxx'' and sys.setlocale LC_ALL - statements in Targits R-import. At some point R just refused to read any special character and just jumped to next file when a special character is observed 

    0

Please sign in to leave a comment.

Didn't find what you were looking for?

New post