John Carney
asked on
How to print out Excel file data in column structure in Python
I'm very new to Python but I've learned enough to print out the data in a specified range on Sheet 1 in a specified Excel workbook. The current code below will do that but in the Terminal window, each 5 column row is printed vertically in one long column so to speak. How would I modify the code to get it to print out with each 5 column row spread out horizontally as it is in Excel? I'm interested in doing that because 1) it would be easier to read, and 2) just to see if Python will do that.
John
path = r'C:\Users\t0122059\Documents\ACDetails.xlsx'
f = open(path, 'rb')
print(f.read())
# https://openpyxl.readthedocs.io/en/stable/usage.html
from openpyxl import load_workbook
wb = load_workbook(path)
for row in range(1, 12):
for col in range(1, 6):
print(wb.worksheets[0].cell(row, col).value)
print('inspect')
Thanks,John
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, gentlemen!
ASKER
Open in new window