# Python sandbox for generated CSV reports

**Use case:** 

Run Python report code, save a generated CSV to Apify storage, and return a structured execution record for automation workflows.

## Input

```json
{
  "language": "python",
  "code": "import csv, json, sys\nrows=json.load(sys.stdin)['rows']\nwith open('report.csv','w',newline='') as f:\n w=csv.DictWriter(f,fieldnames=['name','score']); w.writeheader(); w.writerows(rows)\nprint(json.dumps({'rowsWritten':len(rows)}))",
  "stdin": {
    "rows": [
      {
        "name": "Alpha",
        "score": 92
      },
      {
        "name": "Beta",
        "score": 87
      }
    ]
  },
  "parseJsonOutput": true,
  "timeoutSeconds": 5,
  "maxOutputBytes": 256000,
  "saveFiles": [
    "report.csv"
  ],
  "maxSavedFileBytes": 100000
}
```

## Output

```json
{
  "status": {
    "label": "Status",
    "format": "string"
  },
  "language": {
    "label": "Language",
    "format": "string"
  },
  "exitCode": {
    "label": "Exit code",
    "format": "integer"
  },
  "durationMs": {
    "label": "Duration (ms)",
    "format": "integer"
  },
  "timedOut": {
    "label": "Timed out",
    "format": "boolean"
  },
  "stdout": {
    "label": "Standard output",
    "format": "string"
  },
  "stderr": {
    "label": "Standard error",
    "format": "string"
  },
  "result": {
    "label": "Parsed result",
    "format": "object"
  },
  "files": {
    "label": "Saved files",
    "format": "array"
  },
  "executedAt": {
    "label": "Executed at",
    "format": "string"
  }
}
```

## About this Actor

This example demonstrates how to use [AI Code Runner Sandbox](https://apify.com/automation-lab/ai-code-runner-sandbox) with a specific input configuration. Visit the [Actor detail page](https://apify.com/automation-lab/ai-code-runner-sandbox) to learn more, explore other use cases, and run it yourself.