Skip to content

feat(csv): add parseLine() convenience for single-line CSV records (refs #3765)#7114

Draft
MukundaKatta wants to merge 1 commit intodenoland:mainfrom
MukundaKatta:feat/csv-simple-api
Draft

feat(csv): add parseLine() convenience for single-line CSV records (refs #3765)#7114
MukundaKatta wants to merge 1 commit intodenoland:mainfrom
MukundaKatta:feat/csv-simple-api

Conversation

@MukundaKatta
Copy link
Copy Markdown

Summary

Refs #3765. Adds parseLine(line: string, options?: ParseLineOptions): string[] — a small synchronous convenience for single-record CSV input. Defaults to comma separator, no trim, strict quotes. Strips leading BOM and a single trailing CR/LF/CRLF.

API

parseLine("a,b,c")                       // ["a", "b", "c"]
parseLine("a\tb", { separator: "\t" })   // ["a", "b"]
parseLine('"a,b","c"')                   // ["a,b", "c"]

Documents the trade-off vs full parse()parseLine doesn't continue multi-line quoted fields, doesn't validate field count across records, and doesn't honor comment lines. For those use parse.

Files changed

  • csv/parse.ts — new ParseLineOptions interface and parseLine() function. Reuses internal Parser class. No breaking changes to existing parse() signature.
  • csv/parse_test.ts — 12 new sub-steps covering basic parsing, quoting, escaped quotes, custom separator (TSV), trimLeadingSpace, lazyQuotes, trailing newline strip, BOM strip, error case, and return-type assertion.

Test plan

  • deno fmt, deno lint, deno check, deno test all clean
  • 11 passed, 0 failed (205 steps)
  • Doc tests pass

…ecords

Adds a small synchronous helper that takes one CSV line and returns
string[]. Useful when callers already have line-split input and don't
need full document/stream semantics.

Refs: denoland#3765
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added the csv label Apr 25, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.61%. Comparing base (e356559) to head (960a7da).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7114   +/-   ##
=======================================
  Coverage   94.61%   94.61%           
=======================================
  Files         633      633           
  Lines       51777    51790   +13     
  Branches     9324     9330    +6     
=======================================
+ Hits        48987    49000   +13     
  Misses       2216     2216           
  Partials      574      574           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants