> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cassidyai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Analyze data in Workflows

> Use Code Execution & File Creation on a Generate Text action to analyze files, generate charts, and create reports.

The **Code Execution & File Creation** setting enables [Workflow](/workflows/overview) actions to automatically analyze, manipulate, and generate insights from structured data files like CSVs, Excel spreadsheets, PowerPoint presentations, Word documents, and PDFs. When enabled, the AI writes code on-the-fly to perform complex data operations, create visualizations, and make direct edits to files — all without requiring technical expertise.

This is particularly useful for tasks like:

* Analyzing sales data exports to uncover trends
* Generating formatted monthly reports with charts and graphs
* Editing custom presentation templates with AI-generated content
* Transforming raw data into polished, branded deliverables

## Enable Code Execution & File Creation

<Steps>
  <Step title="Add a Generate Text action">
    In your [Workflow editor](/workflows/building), click the **+** button to add a new action and select **Generate Text**.

    <Frame>
      <img src="https://mintcdn.com/cassidy/MZZYXYVeCvthpwjt/images/workflows/data-analysis-add-generate-text.png?fit=max&auto=format&n=MZZYXYVeCvthpwjt&q=85&s=653633101905293a1e7284156b68d802" alt="Adding a Generate Text action to a Workflow" width="1004" height="492" data-path="images/workflows/data-analysis-add-generate-text.png" />
    </Frame>
  </Step>

  <Step title="Enable Code Execution & File Creation">
    In the action's settings panel, expand **Code Execution & File Creation** and turn on the setting.

    <Note>Screenshot needed: Generate Text action settings with Code Execution & File Creation enabled.</Note>

    This allows the action to process file attachments and generate insights by writing and executing code behind the scenes.
  </Step>
</Steps>

## Use an Agent with Code Execution & File Creation

The [Generate Text with Agent](/reference/actions/generate-text-with-agent) action inherits its capabilities and advanced settings from the selected [Agent](/agents/overview). New custom Agents have **Code Execution & File Creation** enabled by default. If data analysis or file generation is missing, edit the Agent and enable **Code Execution & File Creation** under **Customize** > **Advanced Settings**.

## Example: Sales data analysis to report

This walkthrough demonstrates a complete data analysis use case — uploading a sales data spreadsheet, analyzing it to create insights and visualizations, and combining results into a PowerPoint presentation.

<Steps>
  <Step title="Set up a file upload trigger">
    Create a Workflow with a [Manual trigger](/reference/triggers/manual) that accepts file uploads. Add a file input field so users can upload Excel or CSV files containing sales data.

    <Frame>
      <img src="https://mintcdn.com/cassidy/MZZYXYVeCvthpwjt/images/workflows/data-analysis-trigger-file-upload.png?fit=max&auto=format&n=MZZYXYVeCvthpwjt&q=85&s=cc464e2c22dd7f7fffdefba2c6d0feaa" alt="Manual trigger configured with a file upload input field" width="948" height="336" data-path="images/workflows/data-analysis-trigger-file-upload.png" />
    </Frame>
  </Step>

  <Step title="Add a Generate Text action to analyze the data">
    Add a **Generate Text** action and reference the uploaded file from your trigger in the prompt. For example:

    *"Analyze the attached sales data and provide key insights including trends over time, top performing products, and revenue patterns. Create a summary of findings with specific metrics. In addition, generate a chart visualization showing sales performance trends by month."*

    <Frame>
      <img src="https://mintcdn.com/cassidy/MZZYXYVeCvthpwjt/images/workflows/data-analysis-configure-prompt.png?fit=max&auto=format&n=MZZYXYVeCvthpwjt&q=85&s=37c1c8d0c13171fcfc6c5d0f47c8d0e6" alt="Generate Text prompt referencing the uploaded file and requesting analysis with chart generation" width="1234" height="526" data-path="images/workflows/data-analysis-configure-prompt.png" />
    </Frame>

    <Tip>You can reference files from trigger attachments or data outputs from previous Workflow steps, allowing you to chain multiple data processing actions together.</Tip>
  </Step>

  <Step title="Enable Code Execution & File Creation">
    Expand **Code Execution & File Creation** and turn on the setting.

    <Note>Screenshot needed: Generate Text action settings with Code Execution & File Creation enabled.</Note>
  </Step>

  <Step title="Add a second action for report generation">
    Add another **Generate Text** action to create a PowerPoint presentation from the analysis. Reference the output from the first step and prompt it to build a report:

    *"Using the analysis results and chart referenced, create a professional PowerPoint presentation with the key findings, chart visualizations, and executive summary slides."*

    <Frame>
      <img src="https://mintcdn.com/cassidy/MZZYXYVeCvthpwjt/images/workflows/data-analysis-powerpoint-prompt.png?fit=max&auto=format&n=MZZYXYVeCvthpwjt&q=85&s=e89dccf53ff91fdb5b8517b6727c07d1" alt="Second Generate Text action configured to create a PowerPoint from analysis results" width="1240" height="484" data-path="images/workflows/data-analysis-powerpoint-prompt.png" />
    </Frame>

    Enable **Code Execution & File Creation** on this action as well so the AI can create and format the presentation.

    <Info>When Code Execution & File Creation is enabled on an action, a **Generated Files** variable appears in the outputs. Reference this variable when passing files between steps.</Info>
  </Step>

  <Step title="Run and review">
    Execute the Workflow by uploading a sales data file. The first step analyzes the data and generates charts, then the second step uses those results to produce a PowerPoint presentation.
  </Step>
</Steps>

## Review results and download files

When a Workflow with Code Execution & File Creation completes, you can inspect exactly what happened and download any generated files.

### View the analysis code

Click **Analyzed sources** in the results panel, then click the code icon (`</>`) next to any analysis step to open a modal showing the Python code the AI wrote to process your data.

<Frame>
  <img src="https://mintcdn.com/cassidy/MZZYXYVeCvthpwjt/images/workflows/data-analysis-analyzed-sources.png?fit=max&auto=format&n=MZZYXYVeCvthpwjt&q=85&s=03d8180fb84cc8a311ca8f979d430ca5" alt="Analyzed sources dropdown in the Workflow results panel" width="1570" height="3040" data-path="images/workflows/data-analysis-analyzed-sources.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/cassidy/MZZYXYVeCvthpwjt/images/workflows/data-analysis-code-modal.png?fit=max&auto=format&n=MZZYXYVeCvthpwjt&q=85&s=a35f42f1b4ffe628b5ad6f3a244fd2f4" alt="Modal showing the Python code the AI used to analyze the data" width="1246" height="1244" data-path="images/workflows/data-analysis-code-modal.png" />
</Frame>

### Download generated files

Any files created during the analysis — charts, presentations, reports — appear with download buttons in the results panel.

<Frame>
  <img src="https://mintcdn.com/cassidy/MZZYXYVeCvthpwjt/images/workflows/data-analysis-download-files.png?fit=max&auto=format&n=MZZYXYVeCvthpwjt&q=85&s=3d3d69857af3dcfad61b26c3a655864b" alt="Download buttons for generated files in the Workflow results panel" width="1596" height="882" data-path="images/workflows/data-analysis-download-files.png" />
</Frame>

### Review the output

Generated presentations include professional slides with your data insights, key metrics, trend analysis, and embedded visualizations.

<Frame>
  <img src="https://mintcdn.com/cassidy/MZZYXYVeCvthpwjt/images/workflows/data-analysis-powerpoint-output.png?fit=max&auto=format&n=MZZYXYVeCvthpwjt&q=85&s=4fdb10e1c8c1d6216ada96e19153dfd6" alt="Generated PowerPoint presentation with data analysis slides and charts" width="2942" height="1662" data-path="images/workflows/data-analysis-powerpoint-output.png" />
</Frame>

## Next steps

<CardGroup cols={2}>
  <Card title="Analyze data with an Agent" icon="chart-bar" href="/guides/analyze-data-with-agent">
    Analyze data interactively in Agent conversations.
  </Card>

  <Card title="Generate Text action" icon="wand-magic-sparkles" href="/reference/actions/generate-text">
    Learn more about the action that powers data analysis in Workflows.
  </Card>

  <Card title="Process data in bulk" icon="table" href="/workflows/bulk-runs">
    Import datasets and run your Workflow at scale.
  </Card>

  <Card title="Create files in Cassidy" icon="file-export" href="/guides/create-files">
    Other ways to generate files through Agents and Workflows.
  </Card>
</CardGroup>
