python read xls 1

python read xls

# credit to Stack Overflow user in the source link

import pandas as pd

# use r before absolute file path
xls = pd.ExcelFile(r"yourfilename.xls")  

# 2 is the sheet number+1 thus 
# if the file has only 1 sheet write 0 in paranthesis
sheetX = xls.parse(2) 
var1 = sheetX['ColumnName']

# 1 is the row number
print(var1[1]) 

Here is what the above code is Doing:
1. Import the pandas library
2. Read the excel file
3. Parse the sheet number
4. Assign the column name to a variable
5. Print the row number

Similar Posts