Search code examples
rcsvutf-8surveymonkey

Read CSV File with specific caractere with R


I'm trying to read a csv file with R exported from Survey Monkey in French which contain special caracteres as "d’administration", "système", "vousÂ" and "double space" that are impossible to kill. This syntax is really difficult to manage, do you have any advice ? do I have to read it as a UTF-8 format. Thanks for your help. Best


Solution

  • I just saw you're reading a CSV file. Here's how to read them correctly, as that other post also indicates: https://sysmod.wordpress.com/2016/08/28/excel-gene-mutation-and-curation/

    If you really want to replace the accented characters with plain ANSI, here's a VBA function: Function UnAccent(ByVal inputString As String) As String ' http://www.vbforums.com/archive/index.php/t-483965.html Dim index As Long, Position As Long Const ACCENTED_CHARS As String = "ŠŽšžŸÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðñòóôõöùúûüýÿøØŸœŒ" Const ANSICHARACTERS As String = "SZszYAAAAAACEEEEIIIIDNOOOOOUUUUYaaaaaaceeeeiiiidnooooouuuuyyoOYoO" For index = 1 To Len(inputString) Position = InStr(ACCENTED_CHARS, Mid$(inputString, index, 1)) If Position > 0 Then Mid$(inputString, index) = Mid$(ANSICHARACTERS, Position, 1) Next UnAccent = inputString End Function