473,395 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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.
Apr 20 '10 #1
1 1473
Glenton
391 Expert 256MB
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
Apr 20 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: duikboot | last post by:
Hi all, I'm trying to export a view tables from a Oracle database to a Mysql database. I create insert statements (they look alright), but it all goes wrong when I try to execute them in Mysql,...
1
by: Gene Hubert | last post by:
I'm looking to use a datagrid in an odd way and not making a lot of progress. I want to read in a text file and then allow a user to arbitraily divide the data into columns. I thought I might be...
12
by: Noel | last post by:
Hello, I'm currently developing a web service that retrieves data from an employee table. I would like to send and retrieve a custom employee class to/from the webservice. I have currently coded...
2
by: Ido Flatow | last post by:
Hi all, I've been exploring the way I can manipulate WSDL.exe using SchemaImporterExtension in order to create a proxy to my liking. My situation is as follows - I have a web site that has...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
3
by: John | last post by:
Hi I have two data adapters bound to two separate tables. How can I; 1. Loop through all records one by one in one of them while reading column values, and 2. Insert a record from data...
3
by: Screaming Eagles 101 | last post by:
Hi, I have an Access MDB database with a Table1. From VBNET I would like to CREATE a NEW table, which is a copy of Table1, but not with the Data, only the definition. I would also like to have...
2
by: Greg Corradini | last post by:
Hello All, A few weeks ago, I wrote two scripts using mx.ODBC on an Access DB. Among other things, both scripts create new tables, perform a query and then populate the tables with data in a...
2
by: bimeldip | last post by:
hi, I would like to create a program that allows users to manipulate a table without going through phpAdmin. I want to create a html form that can describe the table in a html page and allow users...
0
by: Ed from AZ | last post by:
I'm using Word 2003. I use a proprietary Java program that takes all the information in the various forms and generates an XML file. There are times I need to move information between files. I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.