PYTIME( ) function

Returns a time value calculated by a function in an external Python script. Data processing in Python is external to Analytics.

Syntax

PYTIME("PyFile,PyFunction" <, field|value <,...n>>)

Parameters

Name Type Description
PyFile,PyFunction

character

The name of the Python script to run followed by a comma and then the name of the function that returns the value:

 "myScript,myFunction"

When specifying the Python script, omit the file extension. The function you call may call other functions within the script or within other scripts, however all scripts that run must be placed inside a folder in the PYTHONPATH system environment variable prior to running.

For more information, see Configuring Python for use with Analytics.

Note

Your PyFunction must return a Python datetime.time object.

field |value <,...n>

optional

character

numeric

datetime

logical

This list of fields, expressions, or literal values to use as arguments for the Python function. The values are passed into the function you call in the order you specify them.

You may include as many arguments as necessary to satisfy the function definition in the Python script.

Note

Use the ALLTRIM() function to remove any leading or trailing spaces from character input: ALLTRIM(str). For more information, see ALLTRIM( ) function.

Output

Datetime.

Examples

Basic examples

Returns `t2122`:

ASSIGN v_time_part = PYTIME("hello,get_time", `20160101 212223`)

External Python script:

# hello.py content
from datetime import time
from datetime import date

def get_time(timestamp):
   return timestamp.time();