Python Forum
Reading Multiple Sheets using Pandas - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Reading Multiple Sheets using Pandas (/thread-21451.html)



Reading Multiple Sheets using Pandas - dhiliptcs - Sep-30-2019

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


RE: Reading Multiple Sheets using Pandas - scidam - Sep-30-2019

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.