[{"LN":770901,"F1126":2,"F1185":2,"F1034":1301,"F65":0},{"LN":770901,"F1126":2,"F1185":2,"F1034":1303,"F65":0},{"LN":770901,"F1126":2,"F1185":2,"F1034":1330,"F65":0},{"LN":770901,"F1126":2,"F1185":2,"F1034":1338,"F65":0},{"LN":770032,"F1126":4,"F1185":4,"F1034":1330,"F65":0},{"LN":770032,"F1126":4,"F1185":4,"F1034":1303,"F65":0},{"LN":770032,"F1126":4,"F1185":4,"F1034":1301,"F65":0},{"LN":770009,"F1126":6,"F1185":6,"F1034":1301,"F65":0},{"LN":770009,"F1126":6,"F1185":6,"F1034":1330,"F65":0},{"LN":770004,"F1126":7,"F1185":7,"F1034":1330,"F65":0},{"LN":770004,"F1126":7,"F1185":7,"F1034":1301,"F65":0},{"LN":770004,"F1126":7,"F1185":7,"F1034":1303,"F65":0},{"LN":770008,"F1126":7385,"F1185":8,"F1034":1303,"F65":0},{"LN":770008,"F1126":7385,"F1185":8,"F1034":1301,"F65":0},{"LN":770008,"F1126":7385,"F1185":8,"F1034":1330,"F65":0},{"LN":770006,"F1126":7023,"F1185":12,"F1034":1330,"F65":0},{"LN":770006,"F1126":7023,"F1185":12,"F1034":1301,"F65":0},{"LN":770006,"F1126":7023,"F1185":12,"F1034":1303,"F65":0},{"LN":770002,"F1126":2000,"F1185":770,"F1034":1301,"F65":0},{"LN":770002,"F1126":2000,"F1185":770,"F1034":1338,"F65":0},{"LN":770006,"F1126":2002,"F1185":772,"F1034":1338,"F65":0},{"LN":770006,"F1126":2002,"F1185":772,"F1034":1332,"F65":0},{"LN":770006,"F1126":2002,"F1185":772,"F1034":1333,"F65":0},{"LN":770006,"F1126":2002,"F1185":772,"F1034":1330,"F65":0},{"LN":770006,"F1126":2002,"F1185":772,"F1034":1331,"F65":0},{"LN":770006,"F1126":2002,"F1185":772,"F1034":1301,"F65":0},{"LN":770006,"F1126":2002,"F1185":772,"F1034":1303,"F65":0},{"LN":770006,"F1126":2002,"F1185":772,"F1034":1308,"F65":0}]

This is what the file I am reading would look like.

I want to compare the "LN" value with the next line and if it is the same I write something down the "F1126" and the "F1034" and "F65" values in a certain way into another file say "test". Once the "LN" values change I write a new piece of information in the "test" file and then fill in the "F1126" and the "F1034" and "F65" values again.

I wanted to know if there was a way we could read a two lines, compare values and write to the "test" file accordingly. I am also wondering if it'll be easier if I change the file to CSV values without the field. something like this?

770901,2,2,1301,0

770901,2,2,1303,0

770901,2,2,1330,0

770901,2,2,1338,0

770032,4,4,1330,0

770032,4,4,1303,0

770032,4,4,1301,0

770009,6,6,1301,0

770009,6,6,1330,0

770004,7,7,1330,0

770004,7,7,1301,0

770004,7,7,1303,0

770008,7385,8,1303,0

770008,7385,8,1301,0

770008,7385,8,1330,0

770006,7023,12,1330,0

770006,7023,12,1301,0

770006,7023,12,1303,0

770002,2000,770,1301,0

770002,2000,770,1338,0

770006,2002,772,1338,0

770006,2002,772,1332,0

770006,2002,772,1333,0

770006,2002,772,1330,0

770006,2002,772,1331,0

770006,2002,772,1301,0

770006,2002,772,1303,0

770006,2002,772,1308,0

770006,2002,772,1319,0

770006,2002,772,1321,0

770007,2005,775,1321,0

Please help,

Thank you!