Some thoughts on using chatGPT to write a program to determine which foods are fresh in Ontario

It is easy to find out which foods are fresh in Ontario. There are several guides, including this one from Foodland Ontario, that can help you with this. However, I wanted a particular guide that would list for me all the fresh foods for a given month only.  And since I couldn’t find a guide like that, I decide to write a python program to make such a guide.

In the past, to write a program like that, I would go through sample code I have, pull out bits of code that were good, and cobble together something from all these bits. Lately, though, I simply ask a service like ChatGPT or others to write the code for me. I find nowadays it’s just so much faster to go that route. Call me lazy. 🙂

Since I wanted this done quickly, I pointed chatGPT at the Foodland Ontario guide and asked it to do the following:

Write a python program that strips out the text on this page https://www.ontario.ca/foodland/page/availability-guide?gad_campaignid=22412095602
and leaves just the foods and the month they are grown on. Include all food that states that is Year Round.

Did ChatGPT do that? Yes, it did. Was the program any good? No, it was not! It somehow looked at that web page and decided the values were stored in a table, even though they were not. The web page is more complex than that and so the program was a pretty failure.

After many prompts, I gave up and took an alternative approach. For this new approach, I stripped out the data manually and created a simple CSV file. I then asked ChatGPT to write a program to process the CSV file. Since it is a simpler file, ChatGPT was able to produce a workable Python program that was able to process the CSV file and output the information I needed.

Perhaps a more skilled prompt engineer could have written a better prompt to process the code. I dunno. I am finding that LLMs — not just ChatGPT — are fine with writing some straightforward code based on non-complex inputs and outputs. They are not so fine once the inputs or outputs get complex. But that’s just my experience. YMMV.

I have also concluded that even warmer months like May in Ontario do not have much in the way of fresh food. No wonder there are so many food stories on asparagus and rhubarb! 🙂 You really need to hit June or later before you get into a cornucopia of fresh produce.

If you’d like to see the end result of my coding, go here to this repo: https://github.com/blm849/ontfoods