[R] read in csv.-data file with blanks and missing values

David McPearson dmcp at webmail.co.za
Mon Jan 18 10:14:50 CET 2016

swizz-john wrote:

> Hi people,
> my task is to analyse data that is formatted like this.
> 28jul2009,1,"ABN Amro",,,,,,,,,,,,,,,,,56.5,
> 29jul2009,1,"ABN Amro",,,,,,,,,,,,,,,,,56.5,
> 30jul2009,1,"ABN Amro",,,,,,,,,,,,,,,,,55,
> 31jul2009,1,"ABN Amro",,,,,,,,,,,,,,,,,55,
> 03aug2009,1,"ABN
> 06aug2009,1,"ABN

## Er - no, it'snot.

> It has 21 columns but not every column has a value, some only have commas
> My file is named: test_data.csv and it is attached here:
> test_data.csv

If I open your attachment with Excel I see what you have above. If I open it
with LibreOffice Calc I see the same as you are getting in R.

When I open test_dta.csv with a plain text editor (I used Tinn-R, Notepad
should also work) I see why you are not getting wjat you expect. Take a
careful look at the data: All the commas are contained withing matching pairs
of quotation marks. Hence they are all treated as plain text by sensible

Hope this helps,

PS - If this comes through as html can someone flame me, please. I'm using a
web based service and don't yet know what format it sends...

South Africas premier free email service - www.webmail.co.za

More information about the R-help mailing list