Available from version v 6.2

Summary

This operator behaves like Python scripting - with input table, but it cannot have an input table from the current data node. It can only be used as the first operation in a data node without a parent node.

It accepts the functions run, and create_table. It does not accept main and simple_main.

All other settings are the same as in Python scripting - with input table.

Examples

Task

Import a CSV file

Settings

  • Python Script:
create_table_from_csv.py
async def create_table(parameters, types, columns, files):
is_first = True
textreader = files.i[0].textreader(newline='\n')
async for l in textreader:
if is_first:
headers = [v.strip(' "\n') for v in l.split(',')]
for col_idx, h in enumerate(headers):
columns[h] = col_idx
is_first = False
else:
fields = [v.strip(' "\n') for v in l.split(',')]
if [ f for f in fields if f ]:
yield fields

Input File

Result


Task

Define a data node start table schema

Settings

  • Python Script:
create_table_from_python.py
def create_table(params, types, columns, files):
types[0] = int
types[1] = str
types[2] = datetime.datetime
types[3] = float
types[4] = bool
columns['Integer Column'] = 0
columns['String Column'] = 1
columns['DateTime Column'] = 2
columns['Float Column'] = 3
columns['Boolean Column'] = 4
return []

Result

Related topics