Tuesday, June 11, 2013

Reading CSV and printing the headers

# Read the raw data
rsm <- read.csv("c:/amadriaga/a_r/rawServerMemory.csv")

# Save the column names to array
headerNames <- colnames(rsm)

# Get count of columns
print (length(rsm))

# Loop on column headers and print the header names
for (colnam in names(rsm)[ 1:length(rsm) ] ){
    # print the column name
    print ( colnam )

    # print the number of columns, this is not changing
    print ( counter <-length(rsm) )

    # determine the column number based on the column name
    # and store to a variable
    columnNumber <- which( colnames(rsm)==colnam )

    # print the column number
    print ( columnNumber )
}

No comments:

Post a Comment