Available custom script instructions
The guides in this section of the Adverity documentation explain how to use the custom script instructions available in Adverity to tailor the data in your data extracts to meet your needs.
The instructions are sorted by the type of actions you can take using the instructions. Click the name of an instruction to find out how to configure this instruction as part of your custom script transformation.
Add columns and rows to your data extract
Use these custom script instructions to add new columns or rows to your data extract. Some of these instructions add new fields with pre-determined or fixed values, and others allow you to use existing fields in the data extract to determine the values in your new columns and rows.
Instruction |
Description |
---|---|
Add a new column to the data extract with moving averages. |
|
Add a new column to the data extract with a specific value in each row. |
|
Add a new column to the data extract with values calculated using data from the current, previous and next columns. |
|
Add a new column to the data extract with values calculated using a Python expression. |
|
Add a new column to the data extract with row numbers. |
|
Add rows to the data extract from another datastream or subtable. |
|
Add new columns to the data extract by capturing parts of the values from an existing column. |
|
Check if certain columns exist in the data extract, and add them if they are missing from the data extract. |
|
Add rows to a data extract containing missing dates in a date range. |
|
Sort a data extract and add a new column displaying the difference between each row and the previous row. |
|
Join data extracts from multiple datastreams into a single data extract. |
|
Add new columns to the data extract by using parts of the values from an existing column. This is a simplified version of the capture instruction. |
|
Add a new column to the data extract containing a resolved URL. |
|
Split values into new columns using a regular expression. |
|
Add a column containing a running total to your data extract. |
|
Separate values contained in lists into columns in a data extract. |
|
Separate values contained in dictionaries into columns in a data extract. |
|
Separate values contained in lists into rows in a data extract. |
Remove columns and rows from your data extract
Use these custom script instructions to select which columns or rows in your data extract to keep, and which to remove from your data extract.
Instruction |
Description |
---|---|
Cache the current state of the data table. |
|
Populate a value table using values from a certain column in a data extract. |
|
Find rows that share common values in a selected column but also contain non-identical values in at least one other column. |
|
Select and keep specific columns in a data extract. |
|
Select and remove specific columns from a data extract. |
|
Select and remove specific columns in a data extract using a regular expression. |
|
Select and keep specific columns from a data extract using a regular expression. |
|
Compare data extracts, and return unique rows into a new data extract. |
|
Find the number of distinct rows in a data extract. |
|
Find and return the duplicated rows in a data extract. |
|
Return a set number of rows from the top of the data extract. |
|
search |
Search for certain values in a data extract and keep the rows containing the values. |
Select and keep rows using a Python expression. |
|
Select and keep rows with a value that matches the value you enter. |
|
Select and keep rows that are empty, or contain |
|
selectgt |
Select and keep rows with a number greater than the number you enter. |
Select and keep rows with a value that matches any of a list of values you enter. |
|
Select rows in a data extract to keep if they match values in a value table. |
|
selectlt |
Select and keep rows with a number less than the number you enter. |
Select and remove rows with a value that matches the value you enter. |
|
Select and keep rows in a selected column that are empty. |
|
Select and remove rows with a value that matches any of a list of values you enter. |
|
Select and remove rows in a selected column that are empty. |
|
Select and keep rows that contain any value in a selected column. |
|
Remove a number of rows from the start of a data extract. |
|
Download data directly from Adverity without a header in the file. |
|
Remove rows from a data extract until a given value is found. |
|
Return a set number of rows from the bottom of a data extract. |
|
Remove leading or trailing whitespace from headers. |
|
Keep only the unique rows in a data extract. |
Change the data in your data extract
Use these custom script instructions to transform the data in your data extract.
You might need to use one of these instructions to convert data (e.g. into numbers or Python datetime format) before using a different custom script instruction that requires data in this format.
Instruction |
Description |
---|---|
Convert existing fields in the data extract by performing calculations on selected values. |
|
Convert existing fields in the data extract by anonymizing the values in the selected fields. |
|
Rename columns in your data extract according to your Data Mapping. |
|
Convert the values in a column of a data extract. |
|
Convert all the values in a data extract. |
|
Convert all the values in a data extract using a Python expression. |
|
Convert dates to Python datetime. |
|
Convert duration data into ISO 8601 format. |
|
Convert numerical characters to numbers. |
|
Convert keys and values within a dictionary into a new format. |
|
Convert a UNIX timestamp into an easy-to-read datetime format. |
|
Use a Python expression to convert values in a selected column. |
|
Convert monetary values from one currency to another. |
|
Update your data extract table by combining existing values into new or existing columns. |
|
Fill empty fields in the data extract using values in the row above. |
|
Fill empty fields in the data extract using values in the column to the left of an empty column. |
|
Encrypt selected columns in a data extract. |
|
Reshape a table by transposing fields into data. |
|
Combine fields from different columns into a single column. The combined values are stored in a JSON-style dictionary. |
|
Combine a defined number of rows into the table header. |
|
Combine data from a sorted data extract with another sorted data extract from a different datastream. |
|
Move a column to a new position in the data extract. |
|
Add new header rows and row values to the data extract. |
|
Add a new header to the data extract. |
|
Transpose distinct data values into the data extract header. This is the opposite of the melt instruction. |
|
Rename columns in a data extract. |
|
Reorder columns in a data extract. |
|
Rename the columns in your data extract. |
|
Sort data in a data extract. |
|
Split a date range across multiple rows in a data extract. |
|
Translate values in your data extract from one language to another. |
|
Swap the positions of rows and columns in a data extract. |
Import data from a specific file type
Use these custom script instructions to import data from a file into your data extract.
Instruction |
Description |
---|---|
Import data from an Apache AVRO file. |
|
Parse a csv file. |
|
Import data from a specific sheet of an Excel file. |
|
Decode or encode a data extract. |
|
Import data with a fixed width from a text file. |
|
Import data from a JSON file. |
|
Import data from a NDJSON (newline delimited JSON) formatted file. |
|
Import data from a Parquet file. |
|
Detects the encoding of data and re-encodes to a given encoding type. |
|
Import data from an SPSS file. |
|
Import data from a text file. |
|
Import data from an XLSX file. |
|
Import data from an XML file. |
|
Import data from a ZIP file. |
Manage your data extract
Use these custom script instructions to manage your data extract without changing the data it contains. You can use these instructions to perform a range of tasks, including the following:
-
Make changes to your data extract using metadata
-
Perform checks to verify the uniqueness and quality of your data
-
Export your data extract by email or in a range of file formats
Instruction |
Description |
---|---|
Save a copy of the data extract into a given file format. |
|
Check if the header contains the expected field names, and raise an error if issues are found. |
|
Perform an action on a data extract if a condition is false. |
|
Send a copy of a data extract by email. |
|
Use a mapping table to create new values based on existing values in a data extract. |
|
Send data to a workspace in Explore & Present. |
|
Add a column to the data extract containing selected data from the metaheader. |
|
Add values to the metadata of a data extract. |
|
Add custom tags to your data extract. |
|
Split a data extract into multiple extracts. |
|
Check if the rows in a data extract are unique. |