Creating a Function : Line

Creating a Function : Line PRODUCT     AVGIDEA, INC. 

The Line function is capable of processing data read from a text file stored on Avgidea Storage, line by line. For example, it can read each line of a CSV file, filter out only specific column data, and re-store it in Storage.


Creating a Line Function

1. Login to the ADP console and select the "Function" -> "Editor" menu.


2. Enter the details of the function, and click the "SAVE" button.

Name : Name of the function

Description : Description of the function

Function Type : Line

3. (Optional) Click on the Attach File button to attach a custom Python package to the function as a Zip file.

* AI models can be included in the package and loaded from within the function.


4. Enter a Python program of your choice in the text area.

In the example on the left, the first line of code splits each line (param1) read from the text file with a "," and stores it in the values array. The second line saves the second data in the array (values[1]) to the output file. In the third line, the processed line number (counter) is printed to the log.

This function will be executed for each line of the input file.


5. Click the "SAVE" button to save the function.


Available Functions and Objects

The following is a list of functions and objects that can be used in the Line function.

param1 : Input One line of data read from the file.

counter : Line number

path : Directory where custom packages are located

out(string) : Output function to output file

log(string) : Output function to the execution log

upload(string) : Function to upload locally located files to Storage