-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Data Parsing Function
Summary 💻
Welcome back from break! Hope you had an amazing Thanksgiving with delicious food 🦃🥧
We have one final task for you this semester: write a function that will parse the data that Rachel uploads for monthly distributions.
For this ticket, you may want to build a small File Upload Button for testing purposes. You can reference
src/components/sprint2/FileUpload.tsx since they did something similar.
Your main goal is to write a parseDistributionData function in src/lib/util.ts that will:
- Take in the sample spreadsheet (in the format we agreed on with Rachel)
- Parse it based on recognizable patterns
- Return the data in a structured object format matching the example below
Here is a sample spreadsheet:
https://docs.google.com/spreadsheets/d/1CPS_NX9LYdJ0o--kdMfSjoloCVsYCuK6yDdkmkt4xLg/edit?usp=sharing
Understanding the Spreadsheet
This little excerpt means:
- Diaper Depot distributed 5,457 diapers and helped 130 children in the given month.
- All distributions went to Waltham, so Waltham gets 5,457 diapers and 130 children helped.
| City | % | Diapers | Children Helped |
|---|---|---|---|
| Waltham | 100% | 5457 | 130 |
-
Family ACCESS distributed 3,807 diapers and helped 75 children.
Their city distributions were:City % Diapers Children Helped Arlington 0% 0 0 Burlington 2% 76.14 1.5 Lexington 0% 0 0 Newton 25% 951.75 18.75 Waltham 70% 2664.9 52.5 Wayland 0% 0 0 Wayland 1% 38.07 0.75 Woburn 2% 76.14 1.5 -
Lexington Food Pantry distributed 3,154 diapers and helped 57 children:
| City | % | Diapers | Children Helped |
|---|---|---|---|
| Lexington | 99% | 3122.46 | 56.43 |
| Woburn | 1% | 31.54 | 0.57 |
In summary:
The formula per city is simply:
organization total * city percentage
Required Return Format
The parsed data should look like this (note that you have to return all partners in the spreadsheet:
[
{
partner_name: "Family ACCESS",
diapers_distributed: 3807,
children_helped: 75,
cities: [
{ city: "Arlington", percentage: 0, diapers: 0, children_helped: 0 },
{ city: "Burlington", percentage: 0.02, diapers: 76.14, children_helped: 1.5 },
{ city: "Lexington", percentage: 0, diapers: 0, children_helped: 0 },
{ city: "Newton", percentage: 0.25, diapers: 951.75, children_helped: 18.75 },
{ city: "Waltham", percentage: 0.70, diapers: 2664.9, children_helped: 52.5 },
{ city: "Wayland", percentage: 0, diapers: 0, children_helped: 0 },
{ city: "Wayland", percentage: 0.01, diapers: 38.07, children_helped: 0.75 },
{ city: "Woburn", percentage: 0.02, diapers: 76.14, children_helped: 1.5 }
]
},
{
partner_name: "Lexington Food Pantry",
...
},
...
]
Parsing Strategy
To parse the spreadsheet correctly, look for:
- Spaces between organization rows. This indicates the first organization serves multiple cities
- No spaces between rows. This indicates the organization serves only one city
Use these structural patterns to extract:
- Organization totals
- Each city’s percentage
- Computed diapers/children per city using the formula above
Deliverables 🚀
- Schedule at least two meetings as a pair
- Create a new branch using the “create a branch” button
- Build a sample File Upload Button if needed for testing
- Write the
parseDistributionDatafunction insrc/lib/util.ts - Ensure the returned structure matches the required format
- Open a PR and request review from @coopergolemme
Tips for success 📈
Where to get help!
Reach out to @dilanurbayraktar and @coopergolemme .