How fetch data from Excel using Python?
I have a code that creates a function called 'main()' that I want to use to get data from Excel and save it into a text file. I have tried to use the xlrd module, but it does not work. This is what I used: import xlrd. Import os. F = open("text.txt", "w") def main(): x = 'C:UsersuserDesktoppythonexcel.xlsx' wb = xlrd.openworkbook(x) sh = wb.sheetbyindex(0) for row in range(sh.nrows): for col in range(sh.ncols): try: if sh.cellvalue(row,col) == 'PERSONA': if sh.cellvalue(row,col) == sh.cellvalue(row,col - 1):
f.write(sh.cellvalue(row,col))
f.write(' else: pass. elif sh.cellvalue(row,col) == 'CID': except IndexError: main(). F.
Related Answers
How do I write to an existing Excel file in Python?
Let's take a step back. In this post, we'll write a simple Python script...
How do I create an Excel spreadsheet in Python?
I have a lot of data in Pandas and it can get quite bi...
How to read Excel in Python using openpyxl?
I am doing my first steps with Python and Python module...