Appending Excel column value as CSV file name - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Appending Excel column value as CSV file name (/thread-36310.html) |
Appending Excel column value as CSV file name - sh1704 - Feb-06-2022 Hi All, I am trying to execute a bunch of queries from an excel and loading the result of each queries in individual CSV files. Below is the python code I'm using. from EXCEL_CONNECTION import * from SNOWFLAKE_CONNECTION import * import pandas cur = ctx.cursor() wb = openpyxl.load_workbook(r"Input file path\QUERY.xlsx") ws = wb.get_sheet_by_name('Sheet1') try: for col in ws.iter_cols(min_row=2, min_col=1): for cols in col: name = (cols.value) for row in ws.iter_rows(min_row=2, min_col=2): for cell in row: cur.execute(cell.value) df = cur.fetch_pandas_all() df.to_csv(r"File_Path" + str(name) + r".csv") finally: print("success") cur.close()After running this Script i'm getting the below error and I could see the result of last query from the excel created as CSV and saved in the file path. could somebody please help me out here
|