Python Forum
Reading Multiple Sheets using Pandas
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Reading Multiple Sheets using Pandas
#1
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
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Import multiple CSV files into pandas Krayna 0 1,694 May-20-2021, 04:56 PM
Last Post: Krayna
  pandas head() not reading all rows naab 0 1,777 Apr-07-2020, 01:06 PM
Last Post: naab
  XLSX file with multiple sheets to josn file ovidius 2 2,192 Apr-05-2020, 09:22 AM
Last Post: ovidius
  pandas str.extract multiple regex groups with OR pythonidae 2 7,813 Dec-19-2019, 05:43 PM
Last Post: pythonidae
  Handling multiple errors when using datafiles in Pandas alphanov 1 1,821 Jul-16-2019, 03:17 AM
Last Post: scidam
  Pandas/Excel, reading from one column writing back to another... williamlombard 1 2,672 Mar-01-2018, 06:02 AM
Last Post: williamlombard
  Reading json file as pandas data frame? Alberto 1 8,309 Feb-05-2018, 12:43 AM
Last Post: snippsat
  Panda Data Frame to Existing Multiple Sheets naveedraza 1 5,634 Jul-11-2017, 12:21 PM
Last Post: naveedraza
  Write data into existing Excel (xlsx) file with multiple sheets BNB 1 15,306 Jun-01-2017, 04:22 PM
Last Post: Larz60+
  Pythonic way to standardize dates across two excel sheets? maco144 1 3,012 Feb-04-2017, 09:29 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020