Data Post-processing
The Post-processing step allows you to modify parsed data before exporting it to webhooks, Zapier etc. Write Python code to add custom formatting and business logic: merge or split fields, format dates, prevent some documents from being exported and much more.
Some popular use cases:
- Normalize fields format.
- Format data to make an API call without passing by an automated platform (Zapier/Make/Pabbly Connect etc.).
- Create, modify, split, merge or remove some fields.
- Add additional business logic.
- Avoid exporting some documents based on certain condition.
data
dictionary.Post-processing in Action
In this video, we'll show you how to use the Post-processing step to filter queries coming in emails from the HARO platform.
Writing Python Code
Available Python libraries
The following Python libraries are available (you don't need to import them):
re | Regular expression operations. |
decimal |
Module provides support for fast correctly rounded decimal floating point arithmetic. |
datetime | Module supplies classes for manipulating dates and times. |
dateparser | Provides modules to easily parse localized dates in almost any string formats commonly found on web pages. |
Python built-in functions
Many Python built-in functions are supported. Here are some of the most useful functions:
str(42.99) |
Returns a string object |
int("42") |
Returns an integer number |
float("42.99") |
Returns a floating point number |
range(0, 4) |
Returns a sequence of numbers, starting from 0 and increments by 1 (by default) |
len("hello") |
Returns the length of an object |
abs(-42.99) |
Returns the absolute value of a number |
max([1, -4]) |
Returns the largest item in an iterable |
min([1, -4]) |
Returns the smallest item in an iterable |
pow(x, y) |
Returns the value of x to the power of y |
filter(function, iterable) |
Construct an iterator from those elements of iterable for which function returns true. |
Please refer to the official documentation to learn more.
Python string methods
Here are some of the most useful string methods:
"hello".upper() |
Converts a string into upper case |
"HELLO".lower() |
Converts a string into lower case |
"hello".capitalize() |
Converts the first character to upper case |
"hello".endswith('o') |
Returns true if the string ends with the specified value |
"hello".startswith('h') |
Returns true if the string starts with the specified value |
" hello ".strip() |
Removes spaces at the beginning and at the end of the string |
"hello world".title() |
Converts the first character of each word to upper case |
"hELLO".swapcase() |
Swaps cases, lower case becomes upper case and vice versa |
"hello world".split(" ") |
Splits the string at the specified separator, and returns a list |
"hello world".replace("hello", "bye") |
Returns a string where a specified value is replaced with a specified value |
"42".isdigit() |
Returns True if all characters in the string are digits |
"hello".isalpha() |
Returns True if all characters in the string are in the alphabet |
"hello42".isalnum() |
Returns True if all characters in the string are alphanumeric |
Please refer to the official documentation to learn more.
Limitations
For reasons of security and simplicity, we use a restricted version of Python. Here are some unsupported features:
- import of additional Python packages
- while loops
print
function- variables starting with underscore:
_foo = 42
- Python classes
Hotkeys
Our code editor supports the following hotkeys:
Ctrl+S
: run and saveCtrl+/
: comment outCtrl+X
: delete lineTab
,Shift+Tab
: indent and outdentCtrl+Z
,Ctrl+Shift+Z
: undo and redoCtrl+F
: search
Mac users: use the Cmd
button instead of Ctrl
.