On 16 January 2013 21:22, 3n2 Solutions <3n2soluti...@gmail.com> wrote: > Say I have a text file (example below) that has multiple records with > the same format but not always the same number of lines. Each record > is separated by the line that starts with “Examining file” as in below > example. If you notice, the 3D Val is not there for the second record. > How do I report that the “3D Val” is not present for that particular > record “8866W2310089.txt”? > Thanks to Alan for his reply.
I don't follow what you mean by 'How do I report that the “3D Val” is not present for that particular record “8866W2310089.txt”?' The obvious answer would be (assuming the filename is currently set to “8866W2310089.txt”): print('3D Val not present in %s' % filename) I wonder if your actual question is: 1) How do I detect that it is not present? - check for a line starting with '3D' while reading the file. 2) How do I mark it is not being present in my data structure? - depends what kind of data structure you are using. A common idiom would be to simply use the value None as a place-holder for situations where the value is not supplied. 3) Something else... > > Examining file: 5521W2310000.txt > > Duration : 0h : 59m > First meas : week : 86 : 1721 > Last meas : week : 89 : 1721 > > Min val : 15 > Max val : 18 > 3D : 3600 100.0% > > summary Total Missed Rate > epoch1 : 1378 0 0\1000 > epoch2 : 2154 1 0\1000 > > > > Examining file: 8866W2310089.txt > > Duration : 0h : 59m > First meas : week : 87 : 1721 > Last meas : week : 84 : 1721 > > Min val : 16 > Max val : 19 > > summary Total Missed Rate > epoch1 : 1378 0 0\1000 > epoch Oscar _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor