aisingapore / TagUI

Free RPA tool by AI Singapore
Apache License 2.0
5.66k stars 585 forks source link

Excel files processing in TagUI #434

Closed Hassan-Ali123 closed 5 years ago

Hassan-Ali123 commented 5 years ago

Hi! I want to know that I have a process to populate some text fields with the info received from Excel file. Is this can be done using TagUI?? If not what is the alternate???

muratcim commented 5 years ago

Hello Hassan

Yes you can do this using python and java script.First you need to install some python dependencies.(openpyxl,simplejson).

I have two rows in the A column of the excel file that I created. 1.san francisco weather 2.los angeles weather

The following code assigns the values in column A of this excel file to a javascript list variable and enters a loop on that variable

columnValues = []
//Open excel file and add values in column A to a list
py begin
from openpyxl import load_workbook
import simplejson as json
workbookSession = load_workbook(filename = 'C:\\excel_files\\weather.xlsx')
sheet=workbookSession.active
column_values = []
for cell in sheet['A']:
    column_values.append(cell.value)
print(json.dumps(column_values))
py finish
columnValues = JSON.parse(py_result)

//loop in list
for (index = 0; index < columnValues.length;index++)
{
    item = columnValues[index]
    https://www.google.co.uk/search?q=`item`
    result = ""

    //google weather value to a variable
    read //*[@id="wob_tm"] to result
    echo result
}

I hope you could help

kensoh commented 5 years ago

Good stuff and sharing @muratcim! Adding on, alternative is saving .xls as .csv and then use load step and JavaScript code to convert into array and extract the values you want.