There is a list of excel files in a directory. The input is a list of sheet names that has to be converted to pdf. So my code has to open the excel file, look for that particular excel sheet and convert that one sheet to pdf. Can anybody suggest which library to use and approach for this. How can I use a variable that has a list of all the required sheet names from all excel files, as argument to open the required excel sheets. Thank you.
INPUT: file1.xls file2.xls file3.xls
sheets in file1: Title, Contents, Summary
sheets in file2: Title, Contents, Summary
sheets in file3: Title, Contents, Summary
Required sheet in file1: Title
Required sheet in file2: Contents
Required sheet in file3: Summary
OUTPUT:
file1_Title.pdf
file2_Contents.pdf
file3_Summary.pdf
Approach: I have a python list with all the sheets in each excel file. And a python list which contains the required sheet to be converted.
import xlrd
book = xlrd.open_workbook(PathforInputFile)
AllSheets = book.sheet_names()
RequiredSheet= line.split("\t")
Code Output:
['Title', 'Contents', 'Summary']
['Title']
['Title', 'Contents', 'Summary']
['Contents']
['Title', 'Contents', 'Summary']
['Summary']