Question

Getting “bot Error” for Python code. While i Convert CSV file to Excel using Python Script

  • 18 August 2023
  • 0 replies
  • 24 views

Badge

Getting “bot Error” for Code.

 

Steps:

  1. Convert to .py File.
  2. Open using A360 Commad
  3. Use Execute Function and call the function  “process_csv_to_excel”
  4. Closed Session

Code:

import pandas as pd
import openpyxl
import os

def process_csv_to_excel():
    csv_file_path = "C:/Automation/Test.csv"
    excel_file_path = "C:/Automation/Test.xlsx"
    
    try:
        # Read the CSV file
        read_file = pd.read_csv(csv_file_path, on_bad_lines='skip', encoding='utf-8')

        # Write to Excel
        read_file.to_excel(excel_file_path, index=None, header=True)

        success_message = "Conversion successful."
    except Exception as e:
        success_message = f"An error occurred: {str(e)}"


0 replies

Be the first to reply!

Reply