Overview
This script converts a .json file to .csv format and optionally drops specified columns. It is designed to run within Alli Workflows and can be used to prepare structured data for downstream processing or handoff to external systems.
Variables
|
Name |
Reference |
Type |
Required |
Default |
Options |
Description |
|---|---|---|---|---|---|---|
|
Input Folder |
FOLDER_NAME |
Alphanumeric |
|
|
|
Name of the local folder on Workflows where the target file lives. If left blank, will look in the home directory. |
|
Input Filename |
FILE_NAME |
Alphanumeric |
✅ |
|
|
Name of the target file on Platform. Can be regex if "Match Type" is set accordingly. |
|
Remove Columns From Output |
ENABLE_DROP |
Boolean |
✅ |
True |
|
Remove Columns from CSV Output |
|
Columns to Drop |
DROP_COLUMNS |
|
|
|
|
Comma-Separated List of Columns To Remove from the Output |
Script Workflow
-
Read Configuration
-
Grabs
FOLDER_NAMEandFILE_NAMEfrom environment variables. -
Verifies that the file is a valid
.json.
-
-
Load JSON Input
-
Parses the
.jsonfile. -
Supports either a single JSON object or a list of records.
-
-
Drop Columns (Optional)
-
If
ENABLE_DROPis"true", removes any keys listed inDROP_COLUMNSfrom each record.
-
-
Write Output
-
Creates a
.csvfile in the same folder with the same base filename. -
Writes the resulting data with headers based on the keys of the first record.
-
-
Logging
-
Prints confirmation of conversion.
-
Prints dropped columns if any were removed.
-
Example
Given: products.json
[ {"id": "123", "name": "Shirt", "price": "29.99", "internal_notes": "New"}, {"id": "456", "name": "Hat", "price": "19.99", "internal_notes": "Old"} ]
With:
-
ENABLE_DROP=true -
DROP_COLUMNS=internal_notes
Output: products.csv
id,name,price 123,Shirt,29.99 456,Hat,19.99
Alli Workflows Best Practices
-
Pair this step after a data API or transformation step that outputs JSON.
-
Use
DROP_COLUMNSto sanitize or redact internal metadata. -
Chain this step into data pipelines feeding into AI models, dashboards, or storage.
⚠️ Notes
-
The script expects well-formed JSON and will raise errors if the input is malformed.
-
Column order is determined by the keys in the first record.
-
Output file will have the same name as input but with a
.csvextension.
🧾 Sample Log Output
Converted ./products.json to ./products.csv Dropped columns: ['internal_notes']