1. Overview
  2. Post-processing
  3. 🐍 Data Post-processing

🐍 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.

Before writing the Python code, it's important to have a basic knowledge of Python and its syntax in order to use this feature efficiently. If you need any help, please don't hesitate to contact our support

Writing Python Code

The parsed data is stored in the data dictionary.

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.

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 save
  • Ctrl+/: comment out
  • Ctrl+X: delete line
  • Tab, Shift+Tab: indent and outdent
  • Ctrl+Z, Ctrl+Shift+Z: undo and redo
  • Ctrl+F: search

Mac users: use the Cmd button instead of Ctrl.


Was this article helpful?