Menu

Parsing Ride-History CSVs Before Drawing Spending Charts
📰

Parsing Ride-History CSVs Before Drawing Spending Charts

DEV Community: vue·Joe Lin·3 days ago
#pHYZPwBC
#devtovue#devto#dev#field#amount
Reading 0:00
15s threshold

A spending chart can look perfectly reasonable while summing the wrong CSV column. I'll walk through the browser-side import pipeline I use to separate correctly parsed fields from values that are actually safe to summarize.

The implementation accepts a ride export, identifies date and amount columns, builds normalized records, and derives summaries and charts from those records. Three details are worth separating from the visualization layer: quoted CSV fields, exact-first header matching, and currencies that must never be treated as interchangeable numbers.

A Comma Is Not Always a Field Separator

Splitting every line on commas works until an address contains a comma. Splitting the whole file into lines first also breaks when a quoted field contains a newline.

The parser in this implementation walks the text character by character. It tracks the current field, the current row, and whether it is inside a quoted field.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.