hi, i'm new in python programming
i'm trying to write a simple program that processes a text file containing grades for a class, extracts the desired grades, count the number of grades in each grade segment and genrate a pie chart for grades,(A1) and here is the text file link
http://pages.cpsc.ucalgary.ca/~zongpeng ... rades1.txt
any help would be appreciated
Mathhax0r 2 Junior Poster in Training
Assuming you already know how to read in from files, there's a wonderful plotting tool for python called matplotlib that will let you make your pie chart. You'll have to get numpy first, though.
Btw, your link to the text file is broken.
Edited by Mathhax0r because: n/a
Stefano Mtangoo 455 Senior Poster
try using link at the top toolbar of your editor. Very helpful to post links.
As buddy said, Matplotlib+wxPython will give you total control. If you do simple plotting, then wxPython have tool for that.
Anyway what do yo want to do with grades? May be python-mysql+wxPython+Matplotlib is all you need
Ri0o 0 Newbie Poster
unfortunatly i'm only allowed to use quickdraw,
i'm only struggling in figuring out how to extract the data from the txt file and assign the numbers to grades ,count how many scored each grade, i know how to make the chart (A1)
http://pages.cpsc.ucalgary.ca/~zongpeng/CPSC231/assignments/A3/grades1.txt
any help or tips would be appreciated
Edited by Ri0o because: n/a
Stefano Mtangoo 455 Senior Poster
Ok, do us a favour,
attach that file to your post. Jus Click reply and you will see button to attach and do it. We cant know the content of the file!
Do it please :)
Stefano Mtangoo 455 Senior Poster
I missed the Link to the file.
As far as I can see, you need to look at csv module to help you to do it.
What I propose is:
1. Open file
2. Get contents of one line
3. get that line with delimiter set to space ie ' '
4. Do whatever you want with data
NB: you can print the result to see what it produces before you use the data. Remember to use:
csv.reader(open('grades1.txt'), delimiter=' ')
More links:
http://docs.python.org/library/csv.html
http://www.velocityreviews.com/forums/t347771-pythons-csv-reader.html
http://tinyurl.com/yf3pqka
Hope it helps
vegaseat 1,735 DaniWeb's Hypocrite Team Colleague
Actually. your raw data file is tab delimited and easily converted into a list of lists. Once that is done you can simply access your specific data by index and looping through the list.
The only special considerations are that the first line is a header and the last line is an 'end of file' marker.
Ri0o 0 Newbie Poster
hi, i'm new in python programming i'm trying to write a simple program that processes a text file containing grades for a class, extracts the desired grades, count the number of grades in each grade segment and genrate a pie chart for grades,(A1) . http://pages.cpsc.ucalgary.ca/~zongpeng/CPSC231/assignments/A3/a3.pdf any help would be appreciated
ID Last First Lecture Tutor A1 A2 A3 A4 A5
6882621 Lee Lisa LO1 TO7 2.0 7.0 1.0 10.0 8.5
5727139 Lee John LO1 TO8 3.5 3.5 8.5 0.0 2.0
4592442 Jones Linda LO0 TO7 8.0 7.5 3.5 1.5 2.0
4194804 Bing Robert LO1 TO0 1.5 8.0 3.5 9.5 8.0
3841058 Johnson Paul LO1 TO6 9.0 2.0 8.0 9.5 2.0
3378161 Freeman John LO1 TO3 2.0 6.0 8.5 8.5 9.5
5140629 Thomas Helen LO0 TO4 0.0 2.0 9.0 10.0 2.0
9347090 Miller Maria LO1 TO1 9.5 9.5 6.5 8.0 9.0
1916293 Jones Robert LO1 TO4 8.5 0.5 10.0 2.0 3.5
6353341 Miller Lisa LO0 TO2 2.0 2.5 3.0 9.0 7.5
7594201 Johnson Linda LO0 TO6 7.0 6.0 6.0 2.0 9.5
9529592 Freeman John LO0 TO3 3.0 9.5 8.5 10.0 9.0
7123952 Moore Maria LO0 TO4 6.5 6.0 5.5 9.0 3.5
5784699 Thomas Maria LO1 TO3 1.5 8.0 9.0 1.0 8.0
7009346 Davis Helen LO1 TO9 1.5 2.0 9.0 1.0 2.0
2235041 Bing James LO1 TO4 6.5 9.0 8.5 9.5 2.5
9295242 Freeman Paul LO1 TO5 6.5 9.5 1.0 4.0 10.0
7501126 Miller Maria LO0 TO0 8.5 3.0 10.0 8.5 8.0
3971527 Davis Maria LO0 TO9 9.0 1.5 2.5 3.5 1.5
0084475 Miller John LO1 TO7 8.5 1.5 9.0 2.5 1.0
2167228 Freeman James LO1 TO5 4.5 8.5 9.5 8.5 10.0
3031060 Freeman Robert LO0 TO9 6.5 9.0 10.0 9.0 3.0
5598222 Bing Lisa LO0 TO9 6.5 2.5 8.0 6.0 0.5
7543280 Lee Mary LO1 TO8 9.5 9.0 8.5 9.5 1.0
6483388 Thomas Linda LO1 TO3 5.5 6.0 1.5 3.0 1.0
3751752 Miller Maria LO1 TO8 9.5 1.5 2.5 9.5 9.0
4395813 Freeman James LO1 TO9 3.5 10.0 5.0 6.5 2.5
0410097 Davis John LO0 TO2 3.5 8.0 0.5 9.0 2.0
3719104 Davis Mary LO0 TO0 1.0 1.5 4.5 3.5 10.0
9959266 Freeman Helen LO0 TO0 8.0 9.0 1.5 7.5 1.5
6861532 Jones Maria LO0 TO2 1.0 3.5 4.5 4.0 2.5
8304781 Johnson Helen LO0 TO6 10.0 9.0 8.0 10.0 7.5
5337432 Taylor James LO1 TO7 1.5 9.0 9.5 2.5 3.5
2602852 Davis Lisa LO0 TO3 1.0 7.5 5.5 1.5 2.0
4293362 Miller Robert LO1 TO7 9.5 4.5 8.5 8.0 8.5
0158170 Lee John LO1 TO1 1.5 3.5 2.5 1.0 9.0
6576801 Jones David LO1 TO6 9.5 4.0 9.5 9.0 10.0
5761759 Lee Robert LO0 TO6 2.5 2.0 9.0 8.0 2.0
9009383 Johnson Paul LO0 TO9 2.0 8.0 2.5 9.5 10.0
9519864 Taylor John LO0 TO4 7.5 2.5 8.5 2.5 10.0
1824451 Taylor James LO0 TO6 9.5 4.5 9.0 8.5 9.0
0423903 Taylor Lisa LO0 TO3 3.0 3.0 3.5 1.5 0.0
9300493 Jones Mary LO1 TO6 10.0 9.0 9.5 9.0 9.5
6429383 Jones Mary LO1 TO3 10.0 8.5 9.0 2.5 9.0
6389950 Lee Robert LO1 TO2 8.5 5.0 1.0 7.0 2.0
8625509 Thomas Mary LO0 TO3 2.0 7.0 8.0 3.0 9.0
3953468 Freeman David LO0 TO9 8.0 8.5 1.0 2.5 2.5
7743437 Bing Linda LO0 TO3 0.0 7.0 8.5 9.5 8.5
4306782 Jones Linda LO0 TO5 2.0 9.5 3.5 7.5 9.5
6299607 Miller James LO0 TO8 8.5 5.0 7.5 9.5 2.0
8295182 Davis Linda LO0 TO9 9.5 9.5 2.5 8.0 8.0
4849291 Freeman Helen LO0 TO5 8.5 2.0 9.5 3.0 8.5
7658018 Thomas Paul LO1 TO2 9.0 8.0 8.5 2.5 9.0
3028404 Jones Paul LO0 TO4 8.5 10.0 6.0 2.0 9.0
1063070 Miller John LO0 TO0 10.0 3.0 4.0 8.0 3.0
0899667 Jones Mary LO1 TO6 2.0 2.0 9.0 10.0 8.0
8459165 Moore John LO1 TO4 2.5 2.5 8.5 1.0 9.5
7503479 Jones Mary LO1 TO3 5.5 8.0 8.5 8.5 10.0
2806139 Miller Paul LO1 TO6 9.5 3.5 9.5 9.5 9.0
5357396 Miller David LO1 TO2 9.5 0.5 8.5 3.0 8.0
2400621 Miller James LO0 TO4 2.0 10.0 3.0 9.5 1.5
7199745 Taylor Maria LO1 TO4 2.0 10.0 6.5 8.0 3.5
7375539 Freeman Mary LO0 TO8 10.0 8.0 7.0 3.0 8.0
7300880 Jones Robert LO0 TO8 2.0 2.0 1.0 9.5 6.0
1332697 Freeman David LO1 TO4 8.0 7.0 1.0 8.5 2.0
3284906 Thomas Maria LO1 TO4 2.5 1.5 3.5 9.0 9.5
5411217 Jones Lisa LO0 TO4 10.0 2.5 10.0 9.0 3.5
0896946 Moore Lisa LO1 TO2 2.5 8.0 7.5 1.5 10.0
7207189 Lee Mary LO1 TO1 8.5 1.0 10.0 10.0 0.0
1243134 Davis John LO1 TO6 1.5 10.0 2.0 2.0 10.0
4463744 Taylor Paul LO0 TO8 0.0 1.5 9.5 0.0 8.0
4662506 Miller Helen LO1 TO6 7.0 10.0 1.5 9.5 8.0
3983380 Davis James LO1 TO9 3.5 8.0 8.0 5.0 8.5
3123601 Freeman Robert LO1 TO2 8.5 8.5 9.0 8.5 1.5
2965912 Bing Linda LO0 TO7 2.0 9.0 8.0 9.0 8.0
7195536 Lee Paul LO1 TO2 1.0 1.0 8.5 2.5 8.0
1886035 Davis Paul LO1 TO1 8.0 8.0 1.5 6.5 10.0
3932253 Thomas Mary LO1 TO5 9.0 9.0 4.5 3.5 6.0
5847220 Bing Paul LO1 TO9 8.5 3.0 8.0 2.5 10.0
4532923 Jones Robert LO0 TO5 2.5 1.5 10.0 9.0 9.5
1881752 Johnson Helen LO1 TO3 2.5 3.5 8.5 2.5 2.0
0834763 Davis John LO0 TO5 9.0 3.5 9.0 8.0 8.5
4786795 Miller Maria LO0 TO3 8.0 8.0 8.0 8.0 4.5
7685892 Thomas Lisa LO1 TO6 3.5 1.5 2.5 7.5 9.0
2798090 Jones John LO0 TO3 8.5 2.0 6.5 2.0 10.0
9609974 Jones Linda LO1 TO9 6.5 7.0 9.0 3.5 8.5
2357750 Thomas Linda LO0 TO8 2.5 8.5 1.0 1.0 3.0
1813468 Lee John LO1 TO3 10.0 1.5 5.5 8.5 10.0
3863617 Moore Mary LO0 TO4 2.0 9.5 2.0 10.0 6.5
7366878 Bing David LO0 TO1 1.5 2.5 10.0 3.5 2.0
8991569 Bing Linda LO1 TO9 1.0 3.0 7.5 8.0 8.5
9882308 Thomas Helen LO1 TO9 9.5 2.0 8.5 10.0 3.5
5973710 Bing Robert LO0 TO8 2.0 9.0 9.0 0.0 2.0
0097002 Thomas David LO0 TO7 8.0 9.0 8.0 2.0 9.5
3275773 Johnson Mary LO0 TO3 10.0 8.5 3.0 9.5 8.5
3183649 Freeman Mary LO0 TO5 1.0 10.0 3.5 9.5 3.0
5055095 Freeman Maria LO1 TO8 2.5 1.0 8.5 8.5 9.0
0785510 Bing Robert LO1 TO8 9.5 1.5 1.5 2.5 3.5
9497502 Taylor Mary LO1 TO6 9.0 9.5 8.5 1.5 8.0
7167053 Johnson James LO0 TO3 9.0 10.0 9.5 1.0 3.5
0724716 Taylor Helen LO1 TO6 9.5 9.0 2.5 2.0 10.0
5745865 Freeman Helen LO0 TO2 6.0 9.0 2.5 10.0 6.5
5865892 Johnson Robert LO0 TO0 9.0 9.0 8.0 0.0 2.0
8097087 Taylor Helen LO1 TO3 2.0 1.5 9.0 9.0 3.5
8707595 Miller Helen LO0 TO8 1.5 8.5 9.5 3.0 2.5
3099178 Jones Maria LO1 TO2 3.0 10.0 2.0 2.5 2.5
6944872 Taylor David LO1 TO0 1.0 7.5 9.0 8.5 9.5
1359192 Davis Linda LO0 TO0 3.5 10.0 6.0 9.5 6.0
0303445 Taylor Robert LO0 TO4 8.5 8.5 3.5 3.0 8.0
9484561 Davis Lisa LO1 TO4 8.0 4.0 1.0 9.5 9.0
7084062 Davis Mary LO0 TO1 9.5 9.5 3.5 6.5 7.5
1571681 Miller Maria LO0 TO1 1.5 8.0 10.0 8.0 10.0
5036203 Davis Helen LO1 TO8 10.0 9.5 3.0 1.0 6.0
3882721 Thomas Paul LO0 TO4 9.0 1.5 1.0 3.0 8.0
0891727 Johnson Helen LO0 TO9 2.5 10.0 9.5 2.5 4.5
4769088 Miller John LO1 TO5 3.5 2.0 3.0 8.0 3.0
4628171 Davis Mary LO1 TO6 3.5 10.0 2.5 6.5 1.0
6522044 Lee Lisa LO0 TO5 10.0 9.0 1.5 9.5 3.0
8513443 Johnson James LO1 TO9 1.0 7.0 1.5 9.0 1.0
2191126 Freeman Robert LO0 TO5 2.5 8.0 3.0 7.5 0.5
0122422 Thomas Paul LO1 TO9 8.5 10.0 2.0 9.0 2.5
4535365 Moore Robert LO0 TO4 8.0 9.0 1.0 8.5 1.0
9478146 Moore Robert LO0 TO5 9.0 10.0 2.5 3.5 2.5
7430187 Taylor Mary LO0 TO9 3.5 2.5 8.5 2.0 8.5
0420782 Jones Paul LO1 TO5 5.0 2.5 9.5 1.0 1.5
9216671 Bing Robert LO0 TO3 9.0 9.5 2.5 3.0 10.0
5680965 Freeman Lisa LO1 TO2 1.0 2.0 1.0 4.0 1.5
1561226 Jones Helen LO0 TO3 10.0 8.5 10.0 10.0 7.0
5800880 Taylor John LO0 TO2 2.0 9.5 8.0 8.5 2.0
4745064 Lee Robert LO0 TO8 1.0 9.0 7.5 9.5 9.5
0124905 Thomas Robert LO0 TO5 0.0 6.0 7.5 3.0 8.5
9412148 Moore Helen LO1 TO3 2.5 10.0 10.0 4.5 8.0
1651802 Lee James LO1 TO9 3.0 9.0 7.0 8.0 0.0
2966435 Taylor John LO1 TO4 3.5 2.0 8.0 2.0 1.0
6418425 Jones Paul LO0 TO3 10.0 3.0 9.0 8.0 3.0
3938727 Johnson John LO1 TO9 9.0 6.0 4.0 8.5 9.5
4174757 Thomas John LO1 TO9 2.0 8.0 2.5 10.0 10.0
7311720 Davis John LO1 TO4 8.5 9.0 1.0 2.5 9.0
8208044 Miller James LO1 TO3 2.0 3.0 9.0 3.5 2.0
5523808 Miller Maria LO0 TO1 3.5 9.0 8.0 9.5 5.0
9568715 Davis David LO0 TO5 8.0 1.5 2.0 9.0 1.0
7210843 Bing David LO1 TO1 9.0 3.0 8.5 9.0 1.5
0982498 Freeman Robert LO0 TO9 3.5 2.5 2.5 1.5 8.0
7993288 Moore David LO0 TO0 9.5 10.0 1.5 1.0 1.5
8400573 Johnson Lisa LO0 TO1 2.0 1.5 9.5 9.5 6.0
2750734 Jones James LO0 TO7 2.5 1.0 10.0 6.5 8.0
2226816 Lee Lisa LO1 TO5 6.0 5.5 3.0 2.0 9.5
5908017 Bing Paul LO1 TO1 9.5 1.5 9.5 3.0 1.0
5701656 Davis David LO1 TO8 9.0 2.5 1.5 8.5 9.5
2899468 Davis James LO1 TO4 4.0 2.5 7.5 2.5 9.5
2445411 Davis Linda LO1 TO5 8.5 10.0 3.5 2.5 7.5
7156143 Thomas David LO0 TO1 5.0 3.5 9.5 10.0 8.5
0278356 Thomas Mary LO1 TO1 0.0 3.5 10.0 8.0 10.0
3305129 Taylor Paul LO1 TO6 9.0 6.0 9.0 6.0 8.0
2241172 Johnson John LO1 TO7 2.0 3.0 8.0 8.0 9.0
7518221 Thomas Mary LO1 TO4 9.5 8.0 8.0 7.5 3.0
6937962 Freeman John LO0 TO9 8.0 3.5 1.0 1.5 3.5
3138608 Lee John LO0 TO1 3.0 10.0 9.0 1.0 9.5
0622474 Jones Maria LO1 TO7 2.0 8.0 5.5 8.0 9.5
3162261 Taylor Linda LO0 TO1 9.0 1.0 8.5 9.0 1.0
6317075 Miller David LO1 TO3 8.5 7.5 2.5 9.5 9.0
4594585 Miller Lisa LO1 TO3 9.5 9.0 3.0 9.0 2.5
8677663 Miller Paul LO1 TO0 9.5 4.0 3.5 9.0 10.0
2118002 Thomas Lisa LO1 TO9 0.5 9.5 9.0 2.0 9.5
6255739 Johnson David LO1 TO2 9.5 3.0 2.5 2.5 3.5
2894340 Thomas Paul LO0 TO0 8.5 9.0 7.0 9.0 2.5
9491631 Miller Paul LO1 TO9 8.5 2.5 7.5 9.0 9.5
0070081 Lee Paul LO1 TO1 2.5 10.0 1.0 9.5 3.5
3982776 Taylor Helen LO1 TO8 1.5 1.0 1.5 1.0 9.0
6210665 Freeman John LO0 TO8 10.0 1.0 2.5 7.0 8.0
8157366 Moore Paul LO0 TO1 9.5 10.0 8.5 10.0 9.5
3723339 Taylor Linda LO1 TO1 2.0 9.5 3.5 8.5 8.5
6526727 Thomas Lisa LO1 TO4 10.0 10.0 8.0 8.5 8.0
6478890 Lee Linda LO0 TO2 2.5 7.0 2.0 2.0 2.5
9642989 Johnson Helen LO0 TO7 9.0 0.0 1.0 9.5 10.0
9369429 Jones James LO0 TO8 1.5 10.0 1.0 9.0 9.5
4280640 Moore Helen LO0 TO4 3.0 9.0 9.5 9.0 9.0
0057063 Jones Mary LO1 TO9 8.0 7.5 3.0 1.5 9.0
0279761 Lee Helen LO1 TO7 1.0 7.0 1.0 9.5 3.0
1940836 Davis Lisa LO0 TO9 1.5 3.5 4.5 8.0 2.5
6359035 Miller James LO0 TO2 10.0 3.0 9.5 3.0 8.5
6178303 Freeman Mary LO0 TO4 9.5 9.5 3.0 8.0 1.5
4531622 Lee Helen LO0 TO0 8.5 2.0 10.0 9.5 6.0
3152656 Jones Robert LO1 TO4 1.5 8.0 7.0 2.5 1.5
1942257 Davis Mary LO0 TO9 9.5 8.5 3.5 9.5 3.5
4910827 Lee John LO0 TO6 8.0 7.0 3.5 2.0 2.0
7998296 Jones Linda LO1 TO1 2.0 9.0 9.0 10.0 9.0
1876861 Bing Lisa LO1 TO8 2.0 9.0 7.0 3.0 1.5
2968691 Thomas David LO0 TO7 8.0 8.5 4.5 3.5 8.5
2281437 Jones Mary LO0 TO0 9.0 2.5 4.5 4.5 9.5
5367989 Lee James LO0 TO1 3.5 3.5 8.0 9.0 6.5
2702361 Miller John LO0 TO4 10.0 1.5 5.5 1.0 1.0
9204661 Freeman Paul LO0 TO6 2.0 3.5 2.5 9.5 9.0
9175403 Jones David LO0 TO8 8.0 3.0 4.5 2.0 1.0
0380188 Davis John LO0 TO5 10.0 9.5 9.5 1.0 8.5
4646732 Thomas Maria LO1 TO3 9.0 4.0 7.0 2.5 2.0
3102045 Thomas Linda LO0 TO7 3.0 8.5 2.5 9.0 9.5
7037617 Thomas Paul LO1 TO1 2.5 2.0 2.0 7.0 5.0
2209727 Jones David LO0 TO3 2.0 3.5 10.0 8.0 5.5
4193846 Freeman Linda LO0 TO8 9.5 3.5 9.0 9.0 8.5
EOF
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.