# Export To CSV

This recipe downloads one metric export and writes it to CSV. Use this recipe when you want a local file for spreadsheet workflows, versioned data snapshots, or notebook inputs.

## Example

```python
import csv
import requests

url = "https://api.growthepie.com/v1/export/txcount.json"
rows = requests.get(url, timeout=30).json()

with open("txcount.csv", "w", newline="", encoding="utf-8") as f:
    writer = csv.DictWriter(f, fieldnames=["metric_key", "origin_key", "date", "value"])
    writer.writeheader()
    writer.writerows(rows)

print("Wrote txcount.csv")
```

## Related Pages

* [Fetch growthepie Data In Python](/recipes-tutorials/recipes/fetch-growthepie-data-in-python.md)
* [Endpoint: export/{metric}.json](/api-reference/api/export-metric-json.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.growthepie.com/recipes-tutorials/recipes/export-to-csv.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
