Prompt Chain

Test LLM Translation Prompts with CSV and Excel Data

Drive promptfoo test cases from CSV or Excel files, including JSON style fields for translation prompts.

Works with excelcsv

80
Spark score
out of 100
Updated 21 days ago
Version 0.121.18

Add to Favorites

Why it matters

Validate and compare multiple language translation prompt variations using structured test cases from CSV or Excel files, enabling systematic evaluation of different translation styles and configurations.

Outcomes

What it gets done

01

Load test cases from CSV or Excel files with JSON configuration fields

02

Compare formal translator prompts against conversational assistant prompts

03

Configure translation style parameters like tone and length via structured data

04

Assert translation quality using case-insensitive content matching

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/pfoo-simple-csv | bash

Steps

Steps in the chain

01
Install read-excel-file package
02
Update promptfooconfig.yaml for Excel
03
Run the evaluation
04
View results in browser

Overview

Simple Csv

A promptfoo example demonstrating CSV and Excel test-case files, including multi-sheet Excel support and JSON style fields, using a translation-prompt illustration. Use it when test cases are more naturally maintained as a spreadsheet. Excel support requires the optional read-excel-file peer dependency.

What it does

This promptfoo example demonstrates using CSV and Excel (XLSX) files as the source of test cases, including JSON-valued fields for configuring style. It uses a translation task as the illustration: two prompt templates (a formal translator and a conversational language assistant) are tested against French and Pirate translations, with tone and length controlled via JSON fields per test row, and results checked with case-insensitive icontains assertions.

When to use - and when NOT to

Use this pattern when your test cases are more naturally maintained as a spreadsheet than as YAML - each row becomes a test case and each column header becomes a variable name, for both CSV and Excel. Excel support is optional and requires installing the read-excel-file peer dependency; without it, only CSV files work out of the box.

Inputs and outputs

npx promptfoo@latest init --example simple-csv
cd simple-csv

promptfoo eval
promptfoo view

To switch from tests.csv to tests.xlsx, install read-excel-file and point promptfooconfig.yaml's tests field at the Excel file. For workbooks with multiple sheets, specify which one to use by name (file://tests.xlsx#MyDataSheet) or by 1-based index (file://tests.xlsx#2).

Integrations

The project ships prompts.txt (both prompt templates), tests.csv and the optional tests.xlsx (the same test cases in each format), and promptfooconfig.yaml tying them together. See promptfoo's CSV Format documentation for the full field reference.

Who it's for

Teams who want to author and maintain promptfoo test cases in a spreadsheet - CSV or Excel, including multi-sheet workbooks - rather than hand-writing YAML test blocks.

Source README

simple-csv (Simple CSV Example)

You can run this example with:

npx promptfoo@latest init --example simple-csv
cd simple-csv

This example demonstrates how to use CSV and Excel files for test cases in promptfoo, including working with JSON fields for language translation tasks.

Features Demonstrated

  • CSV and Excel (XLSX) test case formats with JSON configuration fields
  • Multiple prompt variations for different translation styles
  • Style configuration via JSON fields (tone, length)
  • Case-insensitive test assertions (icontains)

Project Structure

  • promptfooconfig.yaml: Main configuration file
  • prompts.txt: Contains two prompt templates:
    1. A formal translator prompt
    2. A conversational language assistant prompt
  • tests.csv: Test cases for French and Pirate translations
  • tests.xlsx: Same test cases in Excel format (optional)

Using Excel Files

To use Excel files instead of CSV:

  1. Install the read-excel-file package (optional peer dependency):

    npm install read-excel-file
    
  2. Update promptfooconfig.yaml to use the Excel file:

    tests: file://tests.xlsx
    

Excel files work exactly like CSV files - each row becomes a test case, and column headers become variable names.

Multi-sheet Excel Files

For workbooks with multiple sheets, you can specify which sheet to use:

### Use a specific sheet by name
tests: file://tests.xlsx#MyDataSheet

### Or by 1-based index (2 = second sheet)
tests: file://tests.xlsx#2

Running the Tests

From the root of this example, you can run the eval as:

promptfoo eval

To view the results in your browser:

promptfoo view

For more details on using CSV and Excel files in promptfoo, see our CSV Format documentation.

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.