Batch Processing using CSV
Explore batch processing using CSV files within Node.js to automate repetitive tasks like creating multiple game entries. Understand how to leverage streams for efficient handling of large data files, parse CSV content, and execute sequential processing with real-world examples.
We'll cover the following...
What if you wanted to batch-create ten games, rather than creating them one by one? There have been many times in my career where I have used CSV files for batch processing. I have found many spreadsheets, used by other teams, with valuable data that I can use to my advantage. Especially in my last company, there was a huge schedule of promotions that would go live with all the information I needed to create them. I deployed all the promotions for a whole month in one go. A stakeholder contacted me and asked if the promotion was done. I said, “Yes, mate, 22 days ago”.
In this lesson, I will demonstrate a simplified example of processing records, one by one, from a CSV file. You will begin by ensuring that your CSV file is consistently formatted and has two columns:
- The name of the game
- The game template it is based on
You will name your file game-releases.csv, which will look like this:
| Name | Template |
|---|---|
| Check Mate Chess | chess |
| Deluxe Backgammon | backgammon |
| Chaps |