About Python to add a value to each file name during file conversion

NishimuraChinatsu-9854 756 Reputation points
2022-09-08T06:37:06.877+00:00

In the following python in the synapse notebook, I would like to add the letters listed for C2 in excel to each file name when converting files. (C2 + each sheet name)
I can't get the python code to work.

import pandas as pd  
  
path = "abfss://workspacedfs.core.windows.net/raw/"  
df = pd.read_excel(path+"*.xlsm", [2,3,4] )  
all_sheets = pd.read_excel(excel_file,sheet_name= ['outlet','product','delivery'])  
sheets = all_sheets.keys()  
      
for sheet_name in sheets:  
     sheet = pd.read_excel(excel_file, sheet_name=sheet_name)  
     sheet.to_csv("abfss://workspace.dfs.core.windows.net/csv/%s.csv" % sheet_name, index=False)
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,360 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. ShaikMaheer-MSFT 37,896 Reputation points Microsoft Employee
    2022-09-09T10:55:41.67+00:00

    Hi @NishimuraChinatsu-9854 , Thanks for posting query in Microsoft Q&A Platform. Any specific error you are seeing? Kindly share error details.

    Did you tried using openpyxl library to read specific cell value? Check below link about openpyxl library.
    https://www.codespeedy.com/how-to-read-cell-value-in-openpyxl-in-python/