[R] reading csv files

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Fri Feb 5 14:57:56 CET 2010


On Fri, Feb 5, 2010 at 10:23 AM, analyst41 at hotmail.com
<analyst41 at hotmail.com> wrote:
> the csv files are downloaded from a database and it looks like some
> character fields contain the CR-LF sequence within them.
>
> This causes R to see a new record/row and the number of rows it sees
> is different (usually higher) from the number of rows actually
> extracted.

 Hard to tell without an example, but I just tried this in a file:

1,2,"this
is a test",99
2,3,"oneliner",45

and:

> read.table("test.csv",sep=",")
  V1 V2              V3 V4
1  1  2 this\nis a test 99
2  2  3        oneliner 45

seemed to work. But if your strings aren't "quoted" (hard to tell
without an example) then you might have to find another way. Hard to
tell without an example.

Barry



More information about the R-help mailing list