Menu

Keep null and zero distinct when exporting Treasury bond value files
📰

Keep null and zero distinct when exporting Treasury bond value files

DEV Community: node·LTD Atlas·10 days ago
#u976wAIs
#devtonodejs#devto#dev#bond#value
Reading 0:00
15s threshold

The U.S. Treasury publishes savings bond values through its Savings Bonds Value Files dataset . Its sb_value endpoint returns an issue year in each row, with separate amount fields for January through December.

That shape creates two easy data-import mistakes: treating a missing cell as zero, and converting decimal dollar strings through floating-point arithmetic before exporting cents.

Here is a small Node.js workflow that keeps those cases separate and produces a CSV suitable for a spreadsheet or a historical-data pipeline.

Start with a fixed historical month

The savings-bond-value-files source includes a dependency-free parser, an API client, a CLI and a recorded official response. Use Node.js 22.12 or newer:

git clone https://github.com/jiankn/savings-bond-value-files.git cd savings-bond-value-files npm test node bin/cli.mjs --period 2023-05 --format csv > values.csv

Enter fullscreen mode

Exit fullscreen mode

The CLI fetches that redemption period from Treasury.…

Continue reading — create a free account

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