Skip to content
Prev 247367 / 398503 Next

CSV value not being read as it appears

I am a bit confused by this. You are doing a transfer from Excel (.xls 
or .xlsx) to .csv, then a subset in R and ending up with a couple of 
entries which are " Open" rather than "Open". So where are they coming 
from? You say they are not in the original Excel, so that suggests the 
transfer to .csv is the problem. I would be very surprised if the subset 
was a problem, but as others have indicated transfer to .csv can be 
downright ugly.

You can check the .csv file by opening it in an editor (I use Emacs). 
Just go to the line and have a look if the extra space is there nestling 
between two commas.

The other advice is, don't go through .csv. Go directly from Excel to R. 
My favourite tools are RODBC and xlsReadWrite for that step. Both work 
extremely well.

As others have indicated, the big bugbear in the .csv route is dates, or 
what Excel decides are dates. My experience was the conversion of New 
Zealand health ID numbers to dates. They are three letters then 4 
digits, so AUG2699 became a date.

David Scott
On 14/01/2011 10:58 p.m., bgreen at dyson.brisnet.org.au wrote: