--- name: csv description: Analyzes a CSV or similar delimited export and answers the user's actual question with numbers, a short written finding and, where it helps, a chart. Use when a user says "look at this CSV", "what's in this export", "which rep closes best", "break this down by month", "find the outliers", or hands over a data file and wants patterns instead of rows. --- # CSV Data Analysis Turns a raw delimited export into an answer. The job is not to describe every column; it is to answer the question the user asked, show the evidence, and be honest about how far the data can be trusted. ## When to use this - The user attaches or points to a .csv, .tsv or similar delimited file and asks a question about it. - The user wants a quick profile of an unfamiliar export before deciding what to do with it. - The user wants a chart, summary table or cleaned copy derived from tabular data. - Not for multi-sheet workbooks with formulas (use a spreadsheet skill) or for files too large to hold in memory without sampling. ## Procedure 1. **Pin down the question.** Ask for it in one sentence if it was not given: "What decision will this analysis feed?" If the user truly has no question, offer three candidate questions based on the column names and let them pick. 2. **Load defensively.** Use Python with pandas (or the equivalent in whatever environment is available). Let the library sniff the delimiter, try UTF-8 then fall back to latin-1, and keep identifier columns such as ZIP codes and account numbers as text so leading zeros survive. 3. **Profile before analyzing.** Report row count, column names with inferred types, missing-value share per column, number of fully duplicated rows, and the min and max of every date and numeric column. Keep this to a compact table. 4. **Fix types explicitly.** Convert dates, strip currency symbols and thousands separators, and normalize obvious category variants (case, trailing spaces). List every transformation you applied; never change values silently. 5. **Check for traps before trusting a number.** Look for duplicate keys, negative values where none should exist, totals rows pasted into the data, mixed currencies or units, and date ranges that stop mid-period. If any exist, say so and state how you handled them. 6. **Answer the question with the simplest method that works.** Group-bys, ratios, medians and top-N tables cover most requests. Prefer the median when the data is skewed, and show counts next to every average so small groups are visible. 7. **Chart only what supports the answer.** One chart per claim: bars for comparing categories, lines for time, scatter for relationships. Sort bars by value, label axes with units, and title the chart with the finding rather than the column names. Save images as PNG and name the file. 8. **State the confidence.** Note sample sizes, gaps, and anything that would change the conclusion. Separate what the data shows from what you are guessing about the cause. 9. **Offer the next step.** Suggest one or two follow-ups, such as a deeper cut or a cleaned export, and wait for the user to choose. ## Output format ```markdown ## Answer ## Evidence ## Data notes - ## Next - ``` Keep the answer first. Put long tables in a saved file and link to it instead of pasting hundreds of rows. ## Guardrails - Never invent a column, value or trend. If a field needed for the question is missing, say so. - Do not overwrite the user's original file; write cleaned output to a new name. - Treat personal data with care: do not print individual-level rows unless asked, and mask identifiers in examples. - If the file is too large to load, process it in chunks or sample it, and state exactly which approach you used. - If a result looks too good or too strange, re-check the join, filter or unit before reporting it. - Round for readability, but keep the unrounded figure available on request.