11 .. ------------- |
11 .. ------------- |
12 |
12 |
13 .. 1. Getting started with lists |
13 .. 1. Getting started with lists |
14 |
14 |
15 .. Author : Nishanth Amuluru |
15 .. Author : Nishanth Amuluru |
16 Internal Reviewer : |
16 Internal Reviewer : Amit |
17 External Reviewer : |
17 External Reviewer : |
18 Checklist OK? : <put date stamp here, if OK> [2010-10-05] |
18 Language Reviewer : Bhanukiran |
|
19 Checklist OK? : <put date stamp here, not OK> [2010-10-05] |
19 |
20 |
20 Script |
21 Script |
21 ------ |
22 ------ |
22 |
23 |
23 Hello friends and welcome to the tutorial on Parsing Data |
24 Hello friends and welcome to the tutorial on Parsing Data |
35 #[Puneeth]: Changed a few things, here. |
36 #[Puneeth]: Changed a few things, here. |
36 |
37 |
37 #[Puneeth]: I don't like the way the term "parsing data" has been used, all |
38 #[Puneeth]: I don't like the way the term "parsing data" has been used, all |
38 through the script. See if that can be changed. |
39 through the script. See if that can be changed. |
39 |
40 |
40 Lets us have a look at the problem |
41 Let us have a look at the problem |
41 |
42 |
42 {{{ Show the slide containing problem statement. }}} |
43 {{{ Show the slide containing problem statement. }}} |
43 |
44 |
44 There is an input file containing huge no. of records. Each record corresponds |
45 There is an input file containing huge no. of records. Each record corresponds |
45 to a student. |
46 to a student. |
46 |
47 |
47 {{{ show the slide explaining record structure }}} |
48 {{{ show the slide explaining record structure }}} |
48 As you can see, each record consists of fields seperated by a ";". The first |
49 As you can see, each record consists of fields seperated by a ";". The first |
49 record is region code, then roll number, then name, marks of second language, |
50 record is region code, then roll number, then name, marks of second language, |
50 first language, maths, science and social, total marks, pass/fail indicatd by P |
51 first language, maths, science and social, total marks, pass/fail indicatd by P |
51 or F and finally W if with held and empty otherwise. |
52 or F and finally W if withheld and empty otherwise. |
52 |
53 |
53 Our job is to calculate the mean of all the maths marks in the region "B". |
54 Our job is to calculate the arithmetic mean of all the maths marks in the region "B". |
54 |
55 |
55 #[Nishanth]: Please note that I am not telling anything about AA since they do |
56 #[Nishanth]: Please note that I am not telling anything about AA since they do |
56 not know about any if/else yet. |
57 not know about any if/else yet. |
57 |
58 |
58 #[Puneeth]: Should we talk pass/fail etc? I think we should make the problem |
59 #[Puneeth]: Should we talk pass/fail etc? I think we should make the problem |
141 |
142 |
142 By now we know enough to seperate fields from the record and to strip out any |
143 By now we know enough to seperate fields from the record and to strip out any |
143 white space. The only road block we now have is conversion of string to float. |
144 white space. The only road block we now have is conversion of string to float. |
144 |
145 |
145 The splitting and stripping operations are done on a string and their result is |
146 The splitting and stripping operations are done on a string and their result is |
146 also a string. hence the marks that we have are still strings and mathematical |
147 also a string. Hence the marks that we have are still strings and mathematical |
147 operations are not possible on them. We must convert them into numbers |
148 operations are not possible on them. We must convert them into numbers |
148 (integers or floats), before we can perform mathematical operations on them. |
149 (integers or floats), before we can perform mathematical operations on them. |
149 |
150 |
150 We shall look at converting strings into floats. We define a float string |
151 We shall look at converting strings into floats. We define a float string |
151 first. Type |
152 first. Type |