HELP - Manipulating csv data to create a table in Python. Thanks!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mizukage
    New Member
    • Apr 2010
    • 2

    HELP - Manipulating csv data to create a table in Python. Thanks!

    Ok, so lets say I have a .csv file called flags.csv, with the following data

    (Column 1)- (Column 2)
    Country- Colour
    Australia- Red
    Australia- Red
    Australia- Red
    America - Red
    UK - Red
    Japan- Red
    China - Red
    Australia- White
    America - White
    UK - White
    Japan - White
    Australia -Blue
    America - Blue
    UK - Blue
    China - Yellow


    I would like to arrange this data so as to present the countries with flags of at least three colours, and the total number of colours they have. I want the output to end up in this format.
    Column1-Column2-Column3-Column4-Column5
    --------- Blue - Red - White - Yellow - Total
    America-- 1 - 3 - 1 - 0 - 5
    Australia- 1 - 1 - 1 - 0 - 3
    UK------- 1 - 1 - 1 - 0 - 3



    I have no idea what the formulas for manipulating the data so as it forms in this way are. Could you please give me some help?

    Thank you.
  • Glenton
    Recognized Expert Contributor
    • Nov 2008
    • 391

    #2
    Can you show us the code you've written so far please! It's hard to engage at this level.

    As a general hint the use of dictionaries would be good. I'll think about it more, when I get the sense you've thought about it more too! ;D

    Comment

    Working...