I am trying to write a script that reads from an Excel file as a template, and then insert new data based on what is read from a .txt file.
I am using the xlrd
module for reading. Currently, I am stuck at the reading portion of the script.
I plan to increment the rowx
and colx
argument variable by 1 each time, so each cell is searched in the Excel file. However, it appears that Python's argument variables cannot be modified ?
The increment in my script modifies the external variable instead. Is there any way to achieve the cell-by-cell value searching ?
# Define variables
switch1 = 1
count = 0
rowx = 0
colx = 0
# Loop
while switch1 == 1 and count < totalCells:
print "AAAA"
cellValue = "Long string in here....."
if sh.cell_value(rowx=0, colx=0) == cellValue:
print "BBBB"
switch1 = 0
rowx += 1
colx += 1
count += 1