Bottom Page

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
scidam wrote Sep-30-2019, 11:19 PM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
Quote
#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.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Handling multiple errors when using datafiles in Pandas alphanov 1 182 Jul-16-2019, 03:17 AM
Last Post: scidam
  Pandas/Excel, reading from one column writing back to another... williamlombard 1 667 Mar-01-2018, 06:02 AM
Last Post: williamlombard
  Reading json file as pandas data frame? Alberto 1 4,930 Feb-05-2018, 12:43 AM
Last Post: snippsat
  Panda Data Frame to Existing Multiple Sheets naveedraza 1 3,161 Jul-11-2017, 12:21 PM
Last Post: naveedraza
  Write data into existing Excel (xlsx) file with multiple sheets BNB 1 9,822 Jun-01-2017, 04:22 PM
Last Post: Larz60+
  Pythonic way to standardize dates across two excel sheets? maco144 1 1,142 Feb-04-2017, 09:29 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)