{"id":44110,"date":"2026-03-25T17:44:05","date_gmt":"2026-03-25T12:14:05","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=44110"},"modified":"2026-03-25T17:44:05","modified_gmt":"2026-03-25T12:14:05","slug":"how-to-use-code-interpreter-in-microsoft-copilot-studio-to-analyze-csv-and-excel-data","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2026\/03\/how-to-use-code-interpreter-in-microsoft-copilot-studio-to-analyze-csv-and-excel-data\/","title":{"rendered":"How to Use Code Interpreter in Microsoft Copilot Studio to Analyze CSV and Excel Data"},"content":{"rendered":"<p><img decoding=\"async\" class=\"alignnone size-full wp-image-44116\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/How-to-Use-Code-Interpreter-in-Microsoft-Copilot-Studio-to-Analyze-CSV-and-Excel-Data.png\" alt=\"\" width=\"2100\" height=\"1200\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/How-to-Use-Code-Interpreter-in-Microsoft-Copilot-Studio-to-Analyze-CSV-and-Excel-Data.png 2100w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/How-to-Use-Code-Interpreter-in-Microsoft-Copilot-Studio-to-Analyze-CSV-and-Excel-Data-300x171.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/How-to-Use-Code-Interpreter-in-Microsoft-Copilot-Studio-to-Analyze-CSV-and-Excel-Data-1024x585.png 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/How-to-Use-Code-Interpreter-in-Microsoft-Copilot-Studio-to-Analyze-CSV-and-Excel-Data-768x439.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/How-to-Use-Code-Interpreter-in-Microsoft-Copilot-Studio-to-Analyze-CSV-and-Excel-Data-1536x878.png 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/How-to-Use-Code-Interpreter-in-Microsoft-Copilot-Studio-to-Analyze-CSV-and-Excel-Data-2048x1170.png 2048w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/How-to-Use-Code-Interpreter-in-Microsoft-Copilot-Studio-to-Analyze-CSV-and-Excel-Data-660x377.png 660w\" sizes=\"(max-width: 2100px) 100vw, 2100px\" \/><\/p>\n<p>Microsoft Copilot Studio introduces Code Interpreter, a powerful capability that enables agents to generate and execute Python code to analyze structured data.<\/p>\n<p>With this feature, agents can perform tasks such as:<\/p>\n<ul>\n<li><strong>Data aggregation<\/strong><\/li>\n<li><strong>Statistical analysis<\/strong><\/li>\n<li><strong>Forecasting<\/strong><\/li>\n<li><strong>Table joins<\/strong><\/li>\n<li><strong>Chart generation<\/strong><\/li>\n<\/ul>\n<p>Code Interpreter allows agents to work with structured file formats such as CSV and Excel, enabling users to ask analytical questions in natural language and receive data-driven insights.<\/p>\n<p><strong>This capability significantly enhances Copilot agents by combining AI reasoning with deterministic data processing.<\/strong><\/p>\n<h3>Example Use Case<\/h3>\n<p>Imagine a sales operations team that stores lead information in a CSV file.<\/p>\n<p>By enabling Code Interpreter in a Copilot agent, users can ask questions such as:<\/p>\n<ul>\n<li>\u201cHow many leads were generated from LinkedIn this month?\u201d<\/li>\n<li>\u201cWhich lead source generated the highest conversions?\u201d<\/li>\n<\/ul>\n<p>The agent will generate Python code, analyze the dataset, and return tables or visualizations automatically.<\/p>\n<h3>Step-by-Step: Use Code Interpreter with Structured Data<\/h3>\n<p><strong>Step 1: Create the Agent<\/strong><\/p>\n<p>Once your structured data file is ready, create a new agent in Copilot Studio.<\/p>\n<ol>\n<li>Open <a href=\"https:\/\/copilotstudio.microsoft.com\/\" target=\"_blank\" rel=\"noopener\">Microsoft Copilot Studio <\/a>&gt; Create an Agent<\/li>\n<li>Provide a name for your agent, such as Sales Data Analyzer.<\/li>\n<li>Configure the environment and enable Generative AI capabilities.<\/li>\n<\/ol>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-44115\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data.jpg\" alt=\"How to Use Code Interpreter in Microsoft Copilot Studio to Analyze CSV and Excel Data\" width=\"1915\" height=\"902\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data.jpg 1915w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-300x141.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-1024x482.jpg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-768x362.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-1536x723.jpg 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-660x311.jpg 660w\" sizes=\"(max-width: 1915px) 100vw, 1915px\" \/><\/p>\n<p><strong>Step 2: Enable File Processing and Code Interpreter<\/strong><\/p>\n<p>To allow the agent to analyze structured files, enable file processing capabilities.<\/p>\n<ol>\n<li>Open your agent &gt; Go to Settings &gt; Select Generative AI.<\/li>\n<li>Under File Processing Capabilities, enable:\n<ul>\n<li>File uploads<\/li>\n<li>Code interpreter<\/li>\n<\/ul>\n<\/li>\n<li>Click Save.<\/li>\n<\/ol>\n<p>Enable file processing and Code Interpreter so the agent can generate Python code to analyze structured data.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-44111\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-2.jpg\" alt=\"How to Use Code Interpreter in Microsoft Copilot Studio to Analyze CSV and Excel Data\" width=\"1920\" height=\"918\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-2.jpg 1920w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-2-300x143.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-2-1024x490.jpg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-2-768x367.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-2-1536x734.jpg 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-2-660x316.jpg 660w\" sizes=\"(max-width: 1920px) 100vw, 1920px\" \/><\/p>\n<p><strong>Step 3: Upload Structured Files<\/strong><\/p>\n<p>Users can provide structured files to the agent in two ways:<\/p>\n<ol>\n<li>During chat<\/li>\n<\/ol>\n<ul>\n<li>Upload CSV or Excel files directly in the chat window.<\/li>\n<\/ul>\n<ol start=\"2\">\n<li>As knowledge sources<\/li>\n<\/ol>\n<ul>\n<li>Add a SharePoint document library containing structured files.<\/li>\n<\/ul>\n<p>Supported formats include:<\/p>\n<ul>\n<li>.csv<\/li>\n<li>.xlsx<\/li>\n<\/ul>\n<p>File limits:<\/p>\n<ul>\n<li>Maximum 16 MB per file<\/li>\n<li>Up to 10 files per conversation<\/li>\n<\/ul>\n<p>Upload structured files so the agent can analyze them and code interpreter gives Python code for better analysis of the data.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-44112\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-3.jpg\" alt=\"How to Use Code Interpreter in Microsoft Copilot Studio to Analyze CSV and Excel Data\" width=\"1918\" height=\"900\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-3.jpg 1918w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-3-300x141.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-3-1024x481.jpg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-3-768x360.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-3-1536x721.jpg 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-3-660x310.jpg 660w\" sizes=\"(max-width: 1918px) 100vw, 1918px\" \/><\/p>\n<h3>Step 4: Test the Agent<\/h3>\n<p>Now test the agent with analytical questions that require calculations or aggregation.<\/p>\n<p>Example prompts:<\/p>\n<ul>\n<li>\u201cHow many leads were generated from each source?\u201d<\/li>\n<\/ul>\n<p>The agent will automatically:<\/p>\n<ol>\n<li>Generate Python code<\/li>\n<li>Execute the code<\/li>\n<\/ol>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-44113\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-4.jpg\" alt=\"How to Use Code Interpreter in Microsoft Copilot Studio to Analyze CSV and Excel Data\" width=\"1916\" height=\"905\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-4.jpg 1916w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-4-300x142.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-4-1024x484.jpg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-4-768x363.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-4-1536x726.jpg 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-4-660x312.jpg 660w\" sizes=\"(max-width: 1916px) 100vw, 1916px\" \/><\/p>\n<p><strong>Step 5: Test the Generated Python Code<\/strong><\/p>\n<p>When Copilot Studio uses Code Interpreter, the agent generates Python code designed to run inside the Microsoft Copilot runtime environment. This environment includes specific interfaces and libraries that are not available in a normal local Python setup.<\/p>\n<p>The generated code usually depends on components such as:<\/p>\n<ul>\n<li>ExecutorInterface<\/li>\n<li>ConnectorClient<\/li>\n<li>ExecutionResult<\/li>\n<li>workerinterfaces<\/li>\n<\/ul>\n<p>These components exist only inside the Copilot Studio execution environment. Because of this, running the generated code directly on a local machine will typically result in an import error unless those dependencies are removed or simulated.<\/p>\n<p>To validate the logic locally, the easiest approach is to extract the core Python logic and run it independently.<\/p>\n<h3>Test the Core Logic Locally<\/h3>\n<p>Create a Python file and write a simplified version of the generated code that focuses only on the data processing and visualization logic.<\/p>\n<p>Below Is the Code: &#8211;<\/p>\n<pre class=\"lang:css gutter:true start:1\">import pandas as pd\r\n\r\n<em>import matplotlib.pyplot as plt<\/em>\r\n\r\n<em>import io<\/em>\r\n\r\n<em>csv_data = (<\/em>\r\n\r\n<em>\u00a0\u00a0\u00a0 \"LeadName,Source,CreatedDate\\n\"<\/em>\r\n\r\n<em>\u00a0\u00a0\u00a0 \"John,Website,2026-03-01\\n\"<\/em>\r\n\r\n<em>\u00a0\u00a0\u00a0 \"Amit,LinkedIn,2026-03-01\\n\"<\/em>\r\n\r\n<em>\u00a0\u00a0\u00a0 \"Sara,Email Campaign,2026-03-02\\n\"<\/em>\r\n\r\n<em>\u00a0\u00a0\u00a0 \"Alex,Website,2026-03-02\\n\"<\/em>\r\n\r\n<em>\u00a0\u00a0\u00a0 \"Priya,LinkedIn,2026-03-03\\n\"<\/em>\r\n\r\n<em>\u00a0\u00a0\u00a0 \"Kevin,Referral,2026-03-03\\n\"<\/em>\r\n\r\n<em>)<\/em>\r\n\r\n<em># Convert CSV text to DataFrame<\/em>\r\n\r\n<em>df = pd.read_csv(io.StringIO(csv_data))<\/em>\r\n\r\n<em># Convert date column<\/em>\r\n\r\n<em>df['CreatedDate'] = pd.to_datetime(df['CreatedDate'])<\/em>\r\n\r\n<em># Filter last 3 months<\/em>\r\n\r\n<em>end_date = pd.to_datetime(\"2026-03-11\")<\/em>\r\n\r\n<em>start_date = pd.to_datetime(\"2025-12-11\")<\/em>\r\n\r\n<em>df_filtered = df[(df['CreatedDate'] &gt;= start_date) &amp; (df['CreatedDate'] &lt;= end_date)]<\/em>\r\n\r\n<em># Group by lead source<\/em>\r\n\r\n<em>grouped = df_filtered.groupby('Source').size().sort_values(ascending=False)<\/em>\r\n\r\n<em>sources_list = list(grouped.index)<\/em>\r\n\r\n<em>counts_list = list(grouped.values)<\/em>\r\n\r\n<em># Create bar chart<\/em>\r\n\r\n<em>plt.figure(figsize=(8,5))<\/em>\r\n\r\n<em>plt.bar(sources_list, counts_list)<\/em>\r\n\r\n<em>plt.title(\"Leads Generated by Source \u2013 Last 3 Months\")<\/em>\r\n\r\n<em>plt.xlabel(\"Lead Source\")<\/em>\r\n\r\n<em>plt.ylabel(\"Number of Leads\")<\/em>\r\n\r\n<em># Save chart &amp; Show chart<\/em>\r\n\r\n<em>plt.savefig(\"leads_by_source_bar.png\")<\/em>\r\n\r\n<em>plt.show()<\/em>\r\n\r\n<em>print(grouped)<\/em><\/pre>\n<h3><img decoding=\"async\" class=\"alignnone size-full wp-image-44114\" style=\"border: 1px solid #000000; padding: 1px; margin: 1px;\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-5.jpg\" alt=\"How to Use Code Interpreter in Microsoft Copilot Studio to Analyze CSV and Excel Data\" width=\"1918\" height=\"895\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-5.jpg 1918w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-5-300x140.jpg 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-5-1024x478.jpg 1024w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-5-768x358.jpg 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-5-1536x717.jpg 1536w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2026\/03\/Analyze-CSV-and-Excel-Data-5-660x308.jpg 660w\" sizes=\"(max-width: 1918px) 100vw, 1918px\" \/><\/h3>\n<h3>Conclusion-<\/h3>\n<p>Code Interpreter enables Copilot Studio agents to analyze structured data by generating and executing Python code dynamically.<\/p>\n<p>This allows users to:<\/p>\n<ul>\n<li>Ask <strong>analytical questions in natural language<\/strong><\/li>\n<li>Receive <strong>accurate results, charts, and summaries<\/strong><\/li>\n<li>Work with <strong>CSV and Excel data without writing code<\/strong><\/li>\n<\/ul>\n<p>By testing the generated logic locally, developers can validate accuracy and ensure reliable outcomes.<\/p>\n<p>Overall, Code Interpreter transforms Copilot agents into powerful data analysis assistants capable of delivering real-time, data-driven insights directly within conversations.<\/p>\n<h3><strong>FAQs <\/strong><\/h3>\n<p><strong>What is Code Interpreter in Copilot Studio?<\/strong><\/p>\n<p>Code Interpreter is a feature that allows Copilot agents to generate and execute Python code to analyze structured data such as CSV and Excel files.<\/p>\n<p><strong>Can Copilot Studio analyze Excel and CSV files?<\/strong><\/p>\n<p>Yes. Copilot Studio supports structured file formats like <span style=\"color: #000000;\">.csv and .xlsx,<\/span> enabling data analysis through Code Interpreter.<\/p>\n<p><strong>Why can\u2019t generated Python code run locally?<\/strong><\/p>\n<p>Because the code depends on Copilot-specific runtime components such as ExecutorInterface and ConnectorClient, which are not available in a standard Python environment.<\/p>\n<p><strong>How can I test Code Interpreter logic locally?<\/strong><\/p>\n<p>Extract the core data processing logic from the generated code and run it independently in a local Python environment.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Microsoft Copilot Studio introduces Code Interpreter, a powerful capability that enables agents to generate and execute Python code to analyze structured data. With this feature, agents can perform tasks such as: Data aggregation Statistical analysis Forecasting Table joins Chart generation Code Interpreter allows agents to work with structured file formats such as CSV and Excel,\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2026\/03\/how-to-use-code-interpreter-in-microsoft-copilot-studio-to-analyze-csv-and-excel-data\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":15,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3313,2361],"tags":[3329],"class_list":["post-44110","post","type-post","status-publish","format-standard","hentry","category-microsoft-copilot-studio","category-technical","tag-analyze-csv-and-excel-data"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/44110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/15"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=44110"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/44110\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=44110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=44110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=44110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}