How to create a CSV Export Template in Copilot on Fabric
This tutorial shows how to create a CSV Export Template in Copilot on Fabric to transform and export a table as a downloadable CSV file. It is useful to automate reports, data sharing and integration with systems that require CSV.
Prerequisites
- Account with access to Microsoft Fabric and permissions to use Copilot in the workspace.
- Table or dataset available in the Lakehouse or Warehouse with sample data.
- Basic knowledge of prompts and the Copilot environment in Fabric.
Step 1: Open Copilot in Fabric and describe the goal
Open Copilot in Fabric in the workspace where the table is located. In the initial prompt clearly describe that you want a Template that generates a CSV from a table, indicating the table name, the columns to include and the formatting rules (for example separator, date format, null handling).
Exemplo de prompt:
"Cria um Template chamado 'ExportCSV_Sales' que exporta a tabela Sales.Lakehouse.SalesData para CSV. Incluir colunas: Date, CustomerID, Amount. Separador ';'. Formatar Date como YYYY-MM-DD. Substituir NULL por vazio. Gerar comando para download e instruções para automatização."
Step 2: Adjust the Template to handle data (cleaning and transformations)
Copilot will suggest a Template with transformation steps. Review and request modifications: normalize dates, remove spaces, convert types and filter rows. Explicitly ask for transformation examples and include a small code snippet if needed (SQL/KQL/Python) for the environment where the table resides.
Exemplo de transformação em SQL (Warehouse):
SELECT
FORMAT(Date,'yyyy-MM-dd') AS Date,
TRIM(CustomerID) AS CustomerID,
CAST(Amount AS DECIMAL(18,2)) AS Amount
FROM Sales.Lakehouse.SalesData
WHERE Amount IS NOT NULL;
Step 3: Generate the export step to CSV
Ask Copilot to add the final step that converts the result to CSV with the chosen separator and handles null values. Depending on the environment, it may generate a direct export command (e.g. in Dataflow, Notebook or SQL script). Validate that the Template includes options for file name and storage location.
Exemplo para Notebook (PySpark) que cria CSV no Lakehouse path:
df = spark.sql("SELECT FORMAT(Date,'yyyy-MM-dd') AS Date, TRIM(CustomerID) AS CustomerID, CAST(Amount AS DECIMAL(18,2)) AS Amount FROM Sales.Lakehouse.SalesData WHERE Amount IS NOT NULL")
df = df.fillna('')
df.coalesce(1).write.option('sep',';').option('header','true').csv('/lakehouse/exports/ExportCSV_Sales')
# O Copilot pode sugerir comandos adicionais para mover/renomear o ficheiro de output
Step 4: Add metadata and parameters to the Template
For reuse, ask Copilot to make the Template parameterizable: allow selecting date range, optional columns, file name and separator. Validate that the parameters have default values and usage instructions in the Template itself.
Exemplo de estrutura de parâmetros (pseudo):
params = {
'start_date': '2026-01-01',
'end_date': '2026-12-31',
'columns': ['Date','CustomerID','Amount'],
'separator': ';',
'output_path': '/lakehouse/exports/ExportCSV_Sales'
}
# O Template usa params para construir a query e o ficheiro CSV
Step 5: Test the Template with Copilot (run and iterate)
Run the Template with a subset of data to validate transformations and CSV format. If the result has issues (wrong delimiters, poorly formatted dates, missing columns), ask Copilot to iterate and fix them. Save versions of the Template with comments about changes.
Sequência de testes recomendada:
1) Executar com parâmetros de teste (pequeno intervalo de datas).
2) Abrir o CSV gerado para validar separador e cabeçalho.
3) Corrigir transformações e repetir.
Verify the result
Confirm that the CSV contains the correct header, the separator is ';', the dates are in YYYY-MM-DD, there are no 'NULL' values and numeric values have two decimal places. Also verify that the file is accessible at the indicated path and that the Template accepts parameters and consistently produces the same format.
Conclusion
You now have a reusable and parameterizable CSV Export Template in Copilot on Fabric to automate data exports. Next steps: integrate the Template into an automation/ETL flow or create a button in Power BI to trigger the export. Tip: always save input and output examples to ease future validation — what is the first file you will export with this Template?