← All projects

generate-csv-report

A script that builds a CSV report from API data using streaming and async iteration, then emails it as a rendered attachment.

hijal/generate-csv-report@ fcb76dc

Problem

Turn a list of records into a CSV file and deliver it by email without holding the whole dataset in memory.

Built with

  • Node.js
  • csv-parse
  • csv-stringify
  • nodemailer
  • Handlebars

Architecture

Report pipeline

Inferred
  1. API records Fetched user data
  2. Async generator Produces rows lazily
  3. CSV stream Serializes each row
  4. Email Sends the attachment

Lazy row production

Inferred

Rows are produced by an async generator and consumed by csv-stringify, so the full dataset is streamed rather than materialised.

Evidence

A Csv class wraps csv-parse and csv-stringify with configurable options (BOM, headers, delimiter, quoting, escaping) and accepts either a file path or a stream, checking file access before reading.

Verified

index.js fetches users from the public jsonplaceholder API and builds CSV rows through an async generator, writing them both to output.csv and to a stream.

Verified

The report is emailed with nodemailer over the SendGrid transport, rendering html and text bodies from Handlebars templates that are compiled once and cached.

Verified

readFile.js and writeFile.js are ad-hoc scripts that exercise the Csv class with console.assert rather than a test runner.

Verified

Contribution

Sole developer

Owner-confirmed sole work

Owner-confirmed: sole, original work. Node streams / async-generator CSV report generation against a public demo API, emailed via nodemailer with Handlebars templates.