Review CSV regressions with Amazon Ergo
Use Amazon Ergo on Bedrock to review a Python CSV parser, reproduce a missing empty field and a stripped quote, and write focused regression tests.
The task
A CSV importer already handles plain text and quoted commas. A pull request adds a cleanup step. You need to decide whether it preserves the data in an exported row.
Inputs for this example
The sample includes both versions of the parser and the two existing assertions. The importer follows Python’s CSV rules and must preserve empty fields and literal quotes.
Run this on Amazon Ergo
Open the code review preset in the request builder and download its JSON. The file contains both versions of the function and the assertions that still pass. It selects the global.amazon.ergo-1.0 inference profile for Amazon Bedrock. Save it beside the Python script below and use an AWS identity with permission to invoke the model. The call uses your AWS account and incurs its normal inference charges.
Compare each proposed test with the behavior of Python’s CSV reader. A trailing comma adds an empty final field. A quotation mark inside a field survives decoding when the input escapes it correctly. Run the proposed assertion against both functions. A useful regression test passes on the original and fails on the proposed change.
import json, boto3
from pathlib import Path
request = json.loads(Path("ergo-request.json").read_text(encoding="utf-8"))
reply = boto3.client("bedrock-runtime", region_name="us-west-2").converse(**request)
print("\n".join(part["text"] for part in reply["output"]["message"]["content"] if "text" in part))Prompt and sample data
Review the following Python 3 change to a CSV importer. It must preserve empty fields, quoted commas, and quote characters inside field values. For each regression you find, give a minimal input, the expected list of fields, the actual result, and a Python assertion that would catch it.
import csv
def original(row):
return next(csv.reader([row]))
def proposed(row):
fields = original(row)
return [value.strip('"') for value in fields if value != ""]
# These two existing tests pass for both versions.
assert proposed("Ada,Paris") == ["Ada", "Paris"]
assert proposed('"Doe, Jane",Boston') == ["Doe, Jane", "Boston"]
Check a trailing empty field and a field whose value ends in a literal quotation mark. Explain which cleanup operation changes each result.
Open this example in the request builder
Check the result
Run original and proposed with the same input. The row Ada, should produce two fields. For a value ending in a literal quote, encode the row with Python’s csv.writer first. Compare both versions against the value you encoded.
Why use Amazon Ergo for this task?
AWS describes software engineering as an intended use for Ergo. A parser review gives the model both the change and the behavior it must preserve. Asking for executable assertions lets a reviewer check each claim against the implementation before putting it in a pull request. Read the AWS model card.