[R-SIG-Mac] Encoding issue with read.csv

David Winsemius dwinsemius at comcast.net
Sat Oct 24 05:17:58 CEST 2009


On Oct 23, 2009, at 3:34 PM, Arcadio Rubio García wrote:

> Hi all,
>
> I've been given a CSV file saved on an old Windows 2000 machine. I
> think it's coded in Windows-1252 (roughly equivalent to ISO-8859-1 I
> think).
>
> When I try to open it with read.csv('foo.csv', encoding =
> 'iso-8859-1') I get a coding error.

It's consider good form to reproduce the entire error message.

>
> However, if I do:
>
> options(encoding = 'iso-8859-1')
> data <- read.csv('foo.csv')
>
> The file is opened smoothly. What am I doing wrong? Shouldn't the
> first work if the second does?

I cannot quite understand why you are annoyed/upset/bothered because  
the file opened smoothly. My reading of the code in read.table, and  
scan suggests that neither accesses the encoding settings that are  
stored in options. These observations suggest to me that your beliefs  
regarding encoding of the file in question may be false or you are  
spelling ISO incorrrectly. I would have expected it to be  
capitalized.  Searching the archives suggests that you may want to try  
encoding = "CP1252" for Windows csv files.

-- 

David Winsemius, MD
Heritage Laboratories
West Hartford, CT



More information about the R-SIG-Mac mailing list