0Pricing
AI Prompt Engineering · Lesson

Asking for Tables and Structured Data

Request markdown tables and structured output for comparison tasks.

Asking for Tables and Structured Data is a free AI Prompt Engineering lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AI Prompt Engineering learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Tables as Output Format

Tables are one of the most useful AI output formats for comparative information. They make relationships between items scannable and allow quick side-by-side analysis.

The key to getting good tables: specify the exact column names, what each column should contain, and how many rows to include.

Basic Table Request

The standard pattern for requesting a markdown table:

'Format as a markdown table with columns: [Column1], [Column2], [Column3].'

Markdown tables render in GitHub, Notion, Obsidian, and most AI chat UIs. They use pipe characters to separate columns and dashes for header separators.

import openai

client = openai.OpenAI(api_key='sk-your-key-here')

response = client.chat.completions.create(
    model='gpt-4o',
    messages=[{
        'role': 'user',
        'content': (
            'Compare Python, JavaScript, and Go for building REST APIs. '
            'Format as a markdown table with columns: '
            'Language, Performance, Learning Curve, Ecosystem, Best Use Case. '
            'One row per language. Be concise — max 8 words per cell.'
        )
    }]
)
print(response.choices[0].message.content)

Comparison Tables

Comparison tables are ideal when choosing between options. Request them with:

  • 'Create a comparison table of X vs Y vs Z...'
  • 'Make a feature comparison table for...'
  • 'Build a pros/cons table comparing...'

Name the options as rows and the evaluation criteria as columns — or the reverse, depending on which layout is more readable for your content.

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=400,
    messages=[{
        'role': 'user',
        'content': (
            'Create a comparison table for three cloud database options: '
            'Supabase, PlanetScale, and Neon.\n'
            'Rows: one per database.\n'
            'Columns: Free tier storage, Scaling model, Pricing at 10GB, '
            'Branching support, SQL compatibility.\n'
            'Format: markdown table. Cell content: max 6 words each.'
        )
    }]
)
print(response.content[0].text)

Feature Matrix Tables

A feature matrix is a table where rows are items and columns are features, with each cell showing a checkmark, score, or brief value. Common uses:

  • Software feature comparison across versions or competitors
  • Plan comparison for SaaS products
  • Technology support matrices (which browser/OS supports what)

Request: 'Create a feature matrix table with checkmarks (yes/no) for each feature.'

import openai

client = openai.OpenAI(api_key='sk-your-key-here')

response = client.chat.completions.create(
    model='gpt-4o',
    messages=[{
        'role': 'user',
        'content': (
            'Create a feature matrix table for our SaaS pricing tiers: Free, Pro, Enterprise.\n'
            'Rows: API access, Custom domains, SSO login, SLA guarantee, Priority support, '
            'Data export, Team collaboration, Audit logs.\n'
            'Columns: Free, Pro, Enterprise.\n'
            'Use: YES / NO / PARTIAL for each cell.\n'
            'Format: markdown table.'
        )
    }]
)
print(response.choices[0].message.content)

Data Tables from Text

One powerful pattern is asking the model to extract information from unstructured text and format it as a table. This is essentially AI-powered data parsing:

'Extract the following information from the text below and format as a table with columns X, Y, Z.'

Always specify the column names explicitly to get consistent structure.

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

meeting_notes = (
    'Sarah will handle the API documentation by next Friday. '
    'John needs to fix the authentication bug — aim for Wednesday. '
    'Maria is responsible for the mobile UI update, due in 2 weeks. '
    'The DevOps team (lead: Alex) must set up staging by Monday. '
    'Carlos will write unit tests — deadline: end of sprint (Thursday).'
)

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=300,
    messages=[{
        'role': 'user',
        'content': (
            'Extract all action items from the meeting notes below. '
            'Format as a markdown table with columns: Task, Owner, Deadline.\n\n'
            f'Meeting notes:\n{meeting_notes}'
        )
    }]
)
print(response.content[0].text)

CSV Output

When you need data for import into a spreadsheet, database, or further processing, request CSV (comma-separated values) output instead of markdown tables.

'Output as CSV rows with a header row' or 'Format as CSV. First line: column headers.'

CSV is portable and can be pasted directly into Excel, Google Sheets, or parsed by code.

import openai
import csv
import io

client = openai.OpenAI(api_key='sk-your-key-here')

response = client.chat.completions.create(
    model='gpt-4o',
    messages=[{
        'role': 'user',
        'content': (
            'Generate 5 sample customer support tickets for an e-commerce store. '
            'Output as CSV with header row. '
            'Columns: ticket_id, customer_name, issue_type, priority, status. '
            'issue_type values: SHIPPING / BILLING / PRODUCT / RETURNS. '
            'priority values: LOW / MEDIUM / HIGH. '
            'status values: OPEN / IN_PROGRESS / RESOLVED. '
            'No markdown formatting — raw CSV only.'
        )
    }]
)

csv_text = response.choices[0].message.content.strip()
reader = csv.DictReader(io.StringIO(csv_text))
for row in reader:
    print(row)

JSON Structured Output

For programmatic use, JSON is often the best format. Request it explicitly:

'Output as a JSON object with keys X, Y, Z.'
'Return a JSON array where each element has properties A, B, C.'

Some models support native JSON mode that guarantees valid JSON output — but even without it, an explicit JSON request and schema description usually produces parseable output.

import anthropic
import json

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=400,
    messages=[{
        'role': 'user',
        'content': (
            'Generate 3 fictional user profiles for testing a fitness app. '
            'Output as a JSON array. '
            'Each object must have exactly these keys: '
            'id (integer), name (string), age (integer 18-65), '
            'fitness_level ("BEGINNER" | "INTERMEDIATE" | "ADVANCED"), '
            'goals (array of strings, max 3), weekly_sessions (integer 1-7). '
            'Output raw JSON only — no explanation, no markdown code fences.'
        )
    }]
)

try:
    data = json.loads(response.content[0].text)
    print(f'Parsed {len(data)} profiles successfully.')
    for profile in data:
        print(f'  {profile["name"]}, {profile["age"]}, {profile["fitness_level"]}')
except json.JSONDecodeError as e:
    print('JSON parse error:', e)

Specifying Cell Content Rules

Table quality improves significantly when you define what is allowed inside each cell:

  • 'Max 5 words per cell' — prevents verbose cells that break table formatting
  • 'Yes/No only' — binary feature matrix
  • 'Dollar amount only, no explanation' — clean pricing tables
  • 'Single word only' — forced brevity
  • 'Rating 1-10' — numeric scoring tables
import openai

client = openai.OpenAI(api_key='sk-your-key-here')

response = client.chat.completions.create(
    model='gpt-4o',
    messages=[{
        'role': 'user',
        'content': (
            'Rate the following programming languages for these criteria.\n'
            'Languages (rows): Python, Rust, TypeScript, Go.\n'
            'Criteria (columns): Speed, Safety, Developer Experience, Job Market, Learning Curve.\n'
            'Cell format: integer score 1-10 only. No words, no explanation inside cells.\n'
            'After the table, add one sentence explaining your scoring philosophy.'
        )
    }]
)
print(response.choices[0].message.content)

Transposed Tables

Sometimes the default row/column orientation is wrong for your data. A transposed table flips rows and columns — useful when you have many attributes but few items.

Request: 'Create a table with items as columns and attributes as rows' or 'Transpose the table so that X are the columns.'

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=300,
    messages=[{
        'role': 'user',
        'content': (
            'Compare two job candidates: Alice and Bob. '
            'Create a transposed table where candidates are COLUMNS and attributes are ROWS. '
            'Attributes (rows): Years Experience, Primary Language, Education, '
            'Previous Employer, Salary Expectation Range. '
            'Format: markdown table. Cell content: factual, max 6 words.\n\n'
            'Alice: 7 years Python/ML, MS Computer Science MIT, ex-Google, expects $180-220k.\n'
            'Bob: 4 years JavaScript/Node, BS from UC Berkeley, ex-Stripe startup, expects $140-170k.'
        )
    }]
)
print(response.content[0].text)

When NOT to Use Tables

Tables are not always the right format. Avoid them when:

  • You have only 2 items — a brief paragraph comparison reads better
  • Cell content varies dramatically in length — tables become unreadable
  • The output will be used in a plain-text environment (email body, SMS)
  • You are generating content for voice output
  • The relationships are hierarchical, not tabular (use nested lists instead)
import openai

client = openai.OpenAI(api_key='sk-your-key-here')

# Table works: structured comparison
table_prompt = (
    'Compare MySQL vs PostgreSQL. '
    'Format: markdown table, columns: Feature, MySQL, PostgreSQL. '
    '6 rows covering: JSON support, Full-text search, Replication, Transactions, License, Best for.'
)

# No table needed: simple 2-option choice with prose reasoning
not_table_prompt = (
    'Should I use SQLite or PostgreSQL for a personal hobby project '
    'that will have at most 5 users? 2-sentence answer, no table.'
)

for label, prompt in [('TABLE APPROPRIATE', table_prompt), ('TABLE OVERKILL', not_table_prompt)]:
    response = client.chat.completions.create(
        model='gpt-4o', max_tokens=200,
        messages=[{'role': 'user', 'content': prompt}]
    )
    print(f'--- {label} ---')
    print(response.choices[0].message.content.strip()[:300])
    print()

Combining Tables with Other Formats

Tables pair well with surrounding prose or lists. A common high-quality output structure:

  1. Brief intro paragraph explaining the comparison criteria
  2. The table for quick scanning
  3. A recommendation paragraph with the final verdict

Request this explicitly: 'Include: 1-sentence intro, the table, then a 2-sentence recommendation.'

import anthropic

client = anthropic.Anthropic(api_key='sk-ant-your-key-here')

response = client.messages.create(
    model='claude-opus-4-5',
    max_tokens=500,
    messages=[{
        'role': 'user',
        'content': (
            'Compare three Python testing frameworks: pytest, unittest, and nose2. '
            'Structure your response as:\n'
            '1. One-sentence intro explaining the comparison scope.\n'
            '2. Markdown table: columns = Framework, Ease of Use, Plugin Ecosystem, '
            'Speed, Community Activity. Rows = one per framework.\n'
            '3. One-sentence recommendation for a team starting a new project.'
        )
    }]
)
print(response.content[0].text)

Knowledge Check

A developer wants to generate sample data for database testing using AI. They need 10 rows of customer data with ID, name, email, country, and account tier. What is the best output format to request?

Tables and Structured Data — Recap

Tables and structured data requests unlock some of AI's most useful output formats. Key techniques:

  • Specify exact column names to get consistent structure
  • Use comparison tables for side-by-side option analysis
  • Use CSV when the data will be processed programmatically
  • Use JSON for API integration and code consumption
  • Define cell content rules: max words, allowed values, rating scale
  • Consider transposing when items outnumber attributes
  • Combine tables with prose for complete, readable documents

Frequently asked questions

Is the “Asking for Tables and Structured Data” lesson free?

Yes — the full text of “Asking for Tables and Structured Data” is free to read here on the web, and the AI Prompt Engineering course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AI Prompt Engineering course, upgrade to CoddyKit PRO.

What will I learn in “Asking for Tables and Structured Data”?

Request markdown tables and structured output for comparison tasks. You practise AI Prompt Engineering with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AI Prompt Engineering?

No prior experience is required. AI Prompt Engineering on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Asking for Tables and Structured Data” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AI Prompt Engineering lesson?

Yes. Every AI Prompt Engineering lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Requesting Lists and Bullet Points
  2. Asking for Tables and Structured Data
  3. Markdown Formatting in Prompts
  4. Plain Text vs Formatted Output
← Back to AI Prompt Engineering