Kaja
Kaja

Reputation: 3057

finding column number of a csv file in r

I have a big csv file. I would like to know, how many columns does it have?

I am loading the file like this:

k<-read.csv("/home/.../BB/test25000m_60hz.csv",header=FALSE)

thank you for your helps

Upvotes: 0

Views: 201

Answers (2)

maloneypatr
maloneypatr

Reputation: 3622

If you're strictly looking for how many columns a csv contains, and not about manipulating/analyzing/processing the data, the following code should work:

length(read.csv("/home/.../BB/test25000m_60hz.csv",
       header=FALSE))

Upvotes: 1

IRTFM
IRTFM

Reputation: 263301

The most useful strategy for looking at a file structure is

table(count.fields(file=file_name,  ___ ) )

In the space for _, one puts the parameters for comment.char , sep,and quote.

Upvotes: 1

Related Questions