Skip to main content

 I have developed the following code. Its throwing bot error. but if i execute it manual it is working fine. When integrating into A360 not working.

 

A360_Python

import re
import datetime

def Pull_LatestDate_RowLocation(input_1):
    with open(input_1,'r') as file:
        Read_lines = file.readlines()
    result = "\n".join(line.rstrip()if isinstance(line,str) else line for line in Read_lines)
    table_data = str(result)
    # initialize latest date variable to None
    latest_date = None
    # iterate through each row in the table
    for i, row in enumerate(table_data.strip().split('\n').1:], start=1):
        # extract the date from the row using regular expressions
        date_match = re.search(r'\d{2}tA-Z]{3}\d{4}', row)
        if date_match:
            # parse the date string into a datetime object
            date_str = date_match.group()
            date_obj = datetime.datetime.strptime(date_str, '%d%b%Y')
            is_XE_occure = re.search(r'\b{}\b'.format(re.escape("AD")),row)
            is_OO_occure = re.search(r'\b{}\b'.format(re.escape("RT")),row)
            # compare the date to the current latest date
            if latest_date is None or date_obj > latest_date:                
                if is_OO_occure:
                    latest_date = date_obj
                    row_Loc = row
                if is_XE_occure:
                    latest_date = date_obj
                    row_Loc = row
    return row_Loc

 

Note:
Session Name : Find_Loc

- Function Name : Pull_LatestDate_RowLocation.
- Input Argument : Passing the file path.
- Running Enterprise
- manually working

- A360 Not working

I resolved the issue.


I´m having troubles excuting python script. It is giving me bot error but when I run the script outside Automation A360 It works fine.


This is my code
 

def CsvToExcel():
  import pandas as pd
  from openpyxl import load_workbook

  #args = param.split(";")
  #csvFile = args 0]
  #excelFile = args=1]
  csvFile = "\\\\somepath\\PhishingResult.csv"
  excelFile = "\\\\somepath\\Phishing Results Report template-2023Q1.xlsx"

  df = pd.read_csv(csvFile, encoding='cp1252')
  book = load_workbook(excelFile)
  ws = book 'Results']

  start_row = ws.max_row
  start_col = 1

  for row in df.itertuples(index=False):
    for i,value in enumerate(row,start_col):
      ws.cell(row=start_row,column=i,value=value)     
    start_row += 1

  book.save(excelFile)
  return 'Success'
 


How did you solved it? Im running thru this error


Reply