Hi, I am not using Python but I have script in python:

part of script

`elif line.find("CONECT") > -1:
                con = line.split()
                line_value = line_value + 1
                #print line_value
                #print con[2]
                try:
                        line_j = "e" + ', ' + str(line_value) + ', ' + con[2] + "\n"
                        output_file.write(line_j)
                        print(line_j)
                        line_i = "e" + ', ' + str(line_value) + ', ' + con[3] + "\n"
                        output_file.write(line_i)
                        print(line_i)
                        line_k = "e"+ ', ' + str(line_value) + ', ' + con[4] + "\n"
                        print(line_k)
                        output_file.write(line_k)
                except IndexError:
                        continue` 

which give .txt output in format

e, 1, 2

e, 1, 3

e, 1, 4

e, 2, 1

e, 2, 3

etc.

I need remove similar lines with the same numbers, but no matter on order this numbers

i.e. line e, 2, 1..

Is it possible? Please help me

Yes, you must just make the number split from file line numeric and check if that line had line_value in it if it is lower than current line_value, as you seem to have line_value always increasing and the lines with second value higher do not need checked. You might add all numbers from the line in set for this check, maybe list of sets.

You have very similar lines in your code, it would better to use loop over the list from third value to end (con[2:]).

This article has been dead for over six months. Start a new discussion instead.