March 2019
Intermediate to advanced
208 pages
5h 11m
English
Now that we have our records and modules set up, we’re going to write a command-line NodeJS program in ReasonML that reads a file of shirt orders, with each order represented as a line of comma-separated values. The program will get the name of the file to read from the command line argument and output a list of sales by size, color, pattern, collar, and cuff type. Here’s what it looks like when it grows up:
| | $ node src/Stats.bs.js orders.csv |
| | Color Quantity |
| | white 118 |
| | blue 114 |
| | red 73 |
| | ... |
Here are the first few lines of a sample input file, with the first line being a header line:
| | Quantity,Size,Color,Pattern,Collar,Sleeve,Cuff |
| | 6,L,white,solid,straight,long,button |
| | 5,L,blue,pinstripe,straight,xlong,button |
| | 5,M,red,check,spread,long,button ... |
Read now
Unlock full access