How can we read specific lines from a text files using python. File
attached.

Suppose we want to read lines starting with 'R|1|^^^' and 'O|1|'

Should we use:

line.startswith(("..", "..", "----"))
H|\^&|||C311^1|||||host|RSUPL^BATCH|P|1
P|1
O|1|9060^MANWAL                
^1^^010|R1|^^^989/\^^^990/\^^^734/\^^^693/\^^^435/\^^^413/\^^^418/\^^^685/\^^^59/\^^^698/\^^^683/\^^^798/\^^^717/\^^^678/\^^^712/\^^^690/\^^^781/|R||||||N||^^||SC|||bmserv|
                              ^                         ^                    ^  
             ^          |||20151126133212|||F
R|1|^^^989/|141|mmol/l||N||F|||||ISE11
C|1|I|0|I
R|2|^^^990/|4.46|mmol/l||N||F|||||ISE11
C|1|I|0|I
R|3|^^^734/|0.2|mg/dl||N||F|||||P1
C|1|I|0|I
R|4|^^^693/|1.77|mg/dl||N||F|||||P1
C|1|I|0|I
R|5|^^^435/|55.2|mg/dl||N||F|||||P1
C|1|I|0|I
R|6|^^^413/|4.65|g/dl||N||F|||||P1
C|1|I|0|I
R|7|^^^418/|26.2|mg/dl||N||F|||||P1
C|1|I|0|I
R|8|^^^685/|77.4|U/l||N||F|||||P1
C|1|I|0|I
R|9|^^^59/|115.0|mg/dl||N||F|||||P1
C|1|I|0|I
R|10|^^^698/|9.5|mg/dl||N||F|||||P1
C|1|I|0|I
R|11|^^^683/|72|U/l||N||F|||||P1
C|1|I|0|I
R|12|^^^798/|190.4|mg/dl||N||F|||||P1
C|1|I|0|I
R|13|^^^717/|110.8|mg/dl||N||F|||||P1
C|1|I|0|I
R|14|^^^678/|7.37|g/dl||N||F|||||P1
C|1|I|0|I
R|15|^^^712/|0.73|mg/dl||N||F|||||P1
C|1|I|0|I
R|16|^^^690/|0.73|mg/dl||N||F|||||P1
C|1|I|0|I
R|17|^^^781/|169.7|mg/dl||N||F|||||P1
C|1|I|0|I
L|1|N
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to