The inspiration is from Hands-on data visualization using p5. And I want the data to change along with user input. A user can input a country or a city name to search for flights from the country or the city.
My first version has the problem that the code works well on my local server but doesn’t work when it is uploaded to Open Processing. The possible reason, I guess, is larger file size of .csv, which is 7.3 MB. The problem is solved by using callback function.
In my second version, I add several embellishments.
Reorganize my code. In my first version, I wrote two blocks of the same code to get information from the .csv file, which looked redundant. So I rewrite these parts this week and use a function to get needed information once the .csv file is loaded.
Add a hint text “Input a city or country name to get flights information”
A new feature that gets the number of flights from the city/country input by a user
Add an error message when a user inputs an invalid name of a city or a country.
Case insensitive string comparison. A city or country name is usually capitalized, but it is easier for a user to input lower case. So case-insensitive string comparison is necessary. My method is converting both city name and user input to upper case, then do the comparison.