Python Forum

Full Version: Reading Multiple Sheets using Pandas
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
HI-

I am trying to read multiple sheets using Pandas, by parameterizing those Sheet names and column names
While reading the parameter, it is considering entire Param as one string

Error:
Error: raise XLRDError('No sheet named <%r>' % sheet_name) xlrd.biffh.XLRDError: No sheet named <"''abc','cbd','efg'">
Params Read from another file
pTabNames='abc','cbd','efg'
pColumnName='col1,col2'

Code:

import sys
import json
import glob
import pandas as pd
import xlrd


pExcelName=lst['pExcelName']
pColumnName=lst['pColumnName']
pTabNames=lst['pTabNames']
pSkipRows=lst['pSkipRows']

tabs=[ pTabNames]

for i in tabs:
     df = pd.read_excel(  pExcelName  , sheet_name= i , skiprows= pSkipRows  , usecols= pColumnName )
kindly assit
I've tried to read excel files using pandas (I prefer to work with a bit simpler format -- csv).
It seems that your tabs variable is a list of len 1, e.g. something like this [('abc','cbd','efg')] (the list includes a tuple). Try it without square brackets: tabs = pTabNames.