statistics.txt
changeset 51 32d854e62be9
parent 50 9d60720b16b0
child 52 53700ad0e71e
child 57 8eb98721a5af
equal deleted inserted replaced
50:9d60720b16b0 51:32d854e62be9
     4 * How to create plots.
     4 * How to create plots.
     5 * How to read data from file and process it.
     5 * How to read data from file and process it.
     6 
     6 
     7 In this session, we will use them and some new concepts to solve a problem/exercise. 
     7 In this session, we will use them and some new concepts to solve a problem/exercise. 
     8 
     8 
     9 We have a file named sslc1.txt. 
     9 We have a file named sslc.txt. 
    10 It contains record of students and their performance in one of the State Secondary Board Examination. It has 180, 000 lines of record. We are going to read it and process this data.
    10 It contains record of students and their performance in one of the State Secondary Board Examination. It has 180, 000 lines of record. We are going to read it and process this data.
    11 We can see the content of file by opening with any text editor.
    11 We can see the content of file by opening with any text editor.
    12 Please don't edit the data.
    12 Please don't edit the data.
    13 This file has a particular structure. Each line in the file is a set of 11 fields:
    13 This file has a particular structure. Each line in the file is a set of 11 fields:
    14 A;015163;JOSEPH RAJ S;083;042;47;AA;72;244;;;
    14 A;015163;JOSEPH RAJ S;083;042;47;AA;72;244;;;
   117 Let's now start off with the code
   117 Let's now start off with the code
   118 
   118 
   119 We first create an empty dictionary
   119 We first create an empty dictionary
   120 
   120 
   121 science = {}
   121 science = {}
   122 now we read the record data one by one from the file sslc1.txt
   122 now we read the record data one by one from the file sslc.txt
   123 
   123 
   124 for record in open('sslc.txt'):
   124 for record in open('sslc.txt'):
   125 
   125 
   126     we split the record on ';' and store them in a list by: fields equals record.split(';')
   126     we split the record on ';' and store them in a list by: fields equals record.split(';')
   127 
   127