Hello,
I have a two-column, CSV file that lists amenities cities have:
ZIP;Amenity
51454;5
51454;6
53130;5
59437;6
63178;1
69029;6
69081;5
69290;5
71540;5
75101;6
75101;6
75101;5
75101;4
etc.
The first colum contains ZIP codes, and the second column contains an amenity for that town (eg. 1=church, 2=school, 3=restaurant, etc.)
![[Image: image.png]](https://i.postimg.cc/kGwrQzRM/image.png)
I need to write a loop that will fill an array:
1. If it doesn't yet exist, add the zip code as a key in that array
2. For that ZIP, if it doesn't exist, add the key for that kind of amenity (ie. 1, 2, 3, etc.), and increment the value (eg. 1=3 means that the town now has three churches).
What kind of data structure do you think is best for that task?
Thank you.
I have a two-column, CSV file that lists amenities cities have:
ZIP;Amenity
51454;5
51454;6
53130;5
59437;6
63178;1
69029;6
69081;5
69290;5
71540;5
75101;6
75101;6
75101;5
75101;4
etc.
The first colum contains ZIP codes, and the second column contains an amenity for that town (eg. 1=church, 2=school, 3=restaurant, etc.)
![[Image: image.png]](https://i.postimg.cc/kGwrQzRM/image.png)
I need to write a loop that will fill an array:
1. If it doesn't yet exist, add the zip code as a key in that array
2. For that ZIP, if it doesn't exist, add the key for that kind of amenity (ie. 1, 2, 3, etc.), and increment the value (eg. 1=3 means that the town now has three churches).
What kind of data structure do you think is best for that task?
Thank you.