processes a series of text file - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: processes a series of text file (/thread-23627.html) |
processes a series of text file - paolozzigiuseppe9 - Jan-09-2020 Hello everyone! I should solve an exercise in python language and I am not able. This is the exercise: "Create a Python program that processes a series of text files that contain information related to a set of recipes. File: Apple Pie.txt Apples, 4 Sugar, 5 Flour, 6 Eggs, 2 File: Spaghetti in white.txt Spaghetti, 100 Each file is called as a recipe. It contains the ingredients of that recipe. Each ingredient also has a quantity. 1. For each ingredient, print how many recipes it is associated with. 2. Find recipes that share at least 2 ingredients. 3. For each recipe print how many are its ingredients. 4. Find recipes with the same ingredients. Thanks in advance! RE: processes a series of text file - perfringo - Jan-09-2020 What have you tried and where did you get stuck? Some ideas: It's unclear whether you have list of filenames on you should scan a directory. You should address that and process all required files. For every file program must do: # read the file: # store data from file (with association between recipe, ingredient, qty) Then you have to query stored data to get answers for 4 questions asked. After identifying general tasks you can proceed with smaller steps: - how to read file - how to process data in file - how to store processed data (which datastructure, which datatype etc) |