Go to example tasks

Generate a file from code and save it

Runs a Python snippet that writes a CSV file (`squares.csv`) during the run and preserves it in the run's key-value store via `saveFiles`. The snippet also prints a small JSON summary. Use this pattern to produce reports, exports or generated assets from code. Adjust `code` and the `saveFiles` list.

Try for free
AI Code Runner Sandbox
AI Code Runner Sandboxparsebird/code-runner-sandbox
Status
Language
Exit code
Signal
+6 fields
Text
Number
Boolean
List
Object

Input

Language:python
Code(required):import csv, json rows = [["id", "square"]] + [[i, i*i] for i in range(1, 11)] with open("squares.csv", "w", newline="") as f: csv.writer(f).writerows(rows) print(json.dumps({"file": "squares.csv", "rows": len(rows) - 1}))
Save files:squares.csv
Timeout (seconds):5

Output fields

Status
Language
Exit code
Signal
Duration (ms)
Timed out
Output truncated
Termination reason
Result parse error
Executed at

How it works

Sign up on Apify or log in

The AI Code Runner Sandbox Actor is ready to run with the inputs already set for "Generate a file from code and save it". Sign up or log in and you'll land in Apify Console with a copy of this exact task.

Start the "Generate a file from code and save it" task

The AI Code Runner Sandbox Actor will start running based on the input automatically. You can also change all the input fields, like language, code, and more, to match your specific use case.

Receive the "Generate a file from code and save it" output

Monitor the progress in real time. You will be notified as soon as your dataset is complete and ready for review. Each result includes data such as status, language, exit code, and more.

Integrate into your workflow

The final output is delivered in JSON, CSV, or Excel format, ready to be plugged into your workflow. You can also run the "Generate a file from code and save it" task via API.

Image

Integrate "Generate a file from code and save it" into your workflow

Connect "Generate a file from code and save it" with 100+ integrations, or run it via API or MCP.

Webhook

Webhook

n8n

n8n

Make

Make

Zapier

Zapier

Airbyte

Airbyte

Keboola

Keboola

IFTTT

IFTTT

Hubspot

Hubspot

GDrive

GDrive

Gmail

Gmail

Apify MCP

Apify MCP

GitHub

GitHub

Slack

Slack

LangChain

LangChain

LlamaIndex

LlamaIndex

Flowise

Flowise

Pinecone

Pinecone

OpenAI

OpenAI

Mastra

Mastra

Clay

Clay