Skip to main content
added 510 characters in body
Source Link
Faheem Mitha
  • 36.1k
  • 33
  • 130
  • 191

R is not my favorite programming language, but it is good for things like this. If your csv file is

***********
foo.csv
***********
 col1, col2, col3
"this, is the first entry", this is the second, 34.5
'some more', "messed up", stuff

insideInside the R interpreter type

> x=read.csv("foo.csv", header=FALSE)

> x
                        V1    col1              V2  col2   V3col3
1 this, is the first entry  this is the second   34.5
2              'some more'           messed up  stuff
 
> x[1]  # first columncol
                        V1col1
1 this, is the first entry
2              'some more'
 
> x[1,] # first row
                        V1    col1              V2  col2  V3col3
1 this, is the first entry  this is the second  34.5
 

With regard to your other requests, for "the ability to select columns based on the column names given in the first row" see

> x["col1"]
                      col1
1 this, is the first entry
2              'some more'

For "support for other quoting styles" see the quote argument to read.csv (and related functions). For "support for tab-separated files" see the sep argument to read.csv (set sep to '\t').

For more information see the online help.

> help(read.csv)

R is not my favorite programming language, but it is good for things like this. If your csv file is

***********
foo.csv
***********
"this, is the first entry", this is the second, 34.5
'some more', "messed up", stuff

inside the R interpreter type

> x=read.csv("foo.csv", header=FALSE)

> x
                        V1                  V2     V3
1 this, is the first entry  this is the second   34.5
2              'some more'           messed up  stuff
 
> x[1]  # first column
                        V1
1 this, is the first entry
2              'some more'
 
> x[1,] # first row
                        V1                  V2    V3
1 this, is the first entry  this is the second  34.5

> help(read.csv)

R is not my favorite programming language, but it is good for things like this. If your csv file is

***********
foo.csv
***********
 col1, col2, col3
"this, is the first entry", this is the second, 34.5
'some more', "messed up", stuff

Inside the R interpreter type

> x=read.csv("foo.csv", header=FALSE)

> x
                     col1                col2   col3
1 this, is the first entry  this is the second   34.5
2              'some more'           messed up  stuff
> x[1]  # first col
                      col1
1 this, is the first entry
2              'some more'
> x[1,] # first row
                      col1                col2  col3
1 this, is the first entry  this is the second  34.5
 

With regard to your other requests, for "the ability to select columns based on the column names given in the first row" see

> x["col1"]
                      col1
1 this, is the first entry
2              'some more'

For "support for other quoting styles" see the quote argument to read.csv (and related functions). For "support for tab-separated files" see the sep argument to read.csv (set sep to '\t').

For more information see the online help.

> help(read.csv)
Source Link
Faheem Mitha
  • 36.1k
  • 33
  • 130
  • 191

R is not my favorite programming language, but it is good for things like this. If your csv file is

***********
foo.csv
***********
"this, is the first entry", this is the second, 34.5
'some more', "messed up", stuff

inside the R interpreter type

> x=read.csv("foo.csv", header=FALSE)

> x
                        V1                  V2     V3
1 this, is the first entry  this is the second   34.5
2              'some more'           messed up  stuff

> x[1]  # first column
                        V1
1 this, is the first entry
2              'some more'

> x[1,] # first row
                        V1                  V2    V3
1 this, is the first entry  this is the second  34.5

> help(read.csv)