Creating multiple python dictionaries from a file

So I have no idea where to begin here but I need to take the information from a file similar to http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data and have the program run a function that will return 3 new dictionaries based on type. In this file there are 3 flower types so I need to have the program read the file and take the measurements and put them in dictionaries for the type of flower. (I hope I am being clear). From there I have a lot that I will have these dictionaries do for other functions but I know how to do that just not sure how to sort this file into the three dictionaries. I am using Python 2.7. Thanks all.

Answers


Read the file line by line. Split each line on ','. Have a dictionary with key as flower type and list of measurements being value. Each time, you get new measurements for the type append to the list.


Need Your Help

Matplotlib, horizontal bar chart (barh) is upside-down

python pandas matplotlib bar-chart

TL'DR, the vertical bar charts are shown in a conventional way -- things line up from left to right. However, when it is converted to horizontal bar chart (from bar to barh), everything is upside-d...

Which dealloc method is called first?

ios objective-c automatic-ref-counting dealloc code-design

Let's say I have a 2 classes, classes A and B. By composition, Class A has an instance of Class B. In other words, Class A is the one creating the instance of Class B.