if a file that has multiple columns, like

1 7 3 8 5 6 
      3 4 5 6 7 8
      1 7 6 4 4 3

i want to read the first row and see if there numbers that are grater than 6. Then add that number to all the number in that column. For Example, for the second column i want to take 7 and add it to 7, 4, and 7. i can read the values and identify which number are grater than 6, but idk how i can add that number the specific column. Please Help!

import xlrd
import os

folder = "data"
dirList=os.listdir(path)

for file in dirList:
        fullpath = os.path.join(folder,file)
        if os.path.isfile(fullpath) == 1:
                wb = xlrd.open_workbook(fullpath)
                sh = wb.sheet_by_index(0)
                for i in range(0, 1):
##                    print sh.row_values(i)
                    for values in sh.row_values(i):
                        if values > 6:
##                            print values
##                            print len(sh.col_values(0))

Collect tuples of column index, value from columns with required value.

A way that is perhaps easier to understand, but slightly more processor intensive, is to store the first record, add up all of the columns from all of the records, and then print the values for the columns > 6 in the first record. And I don't understand what the variable "idk" is used for.

'idk' means i dont know.

pyTony--i have multiple files. And one file might have a number grater than 6 in the first column, but the other files might have a number grater than 6 in the third column. so i cant specifically tell it the fist column or the third column or.....

Of course, the values of columns must be collected from first row in each file, logical thing would be to make function for processing and calling it with each file as argument. You allready told that before.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.