Reputation: 51
I'm using openpyxl-2.4.0-b1 and Python version 34. Following is my code:
from openpyxl import load_workbook from openpyxl import Workbook
filename= str(input('Please enter the filename name, with the entire path and extension: '))
wb = load_workbook(filename)
ws = wb.worksheets[0]
row_main = 1
#Main Program starts here. Loop for the entire file
print ('Col =', ws.max_column())
while (row_main <(ws.max_row())): #Process rows for each column
print ('ROW =', row_main)
row_main += 1
It runs into an error: Traceback (most recent call last): print ('Col =', ws.max_column()) TypeError: 'int' object is not callable
I can't use get because it has been deprecated. Many thanks in advance.
Upvotes: 2
Views: 4710
Reputation: 744
import pandas as pd
name_of_file = "test.xlsx"
data = pd.read_excel(name_of_file)
total_rows = len(data)
total_columns = len(data.columns)
print(total_rows, total_columns)
Upvotes: 0
Reputation: 46678
As max_column
is property
, so just use the name to get its value:
print('Col =', ws.max_column)
Also apply on max_row
:
while (row_main < ws.max_row):
Upvotes: 5