Home > other >  How python read TXT content and according to a certain range to delete a certain number and line num
How python read TXT content and according to a certain range to delete a certain number and line num

Time:09-26

For help, please guide, thank you!
There is a TXT, such as
1. Jpg (829, 792) (976, 888) 0.99
10. Jpg (843, 651) (993, 750) 0.99
100. Jpg (1529, 151) (1683, 228) 0.87
101. Jpg (819, 655) (967, 754) 0.99
103. Jpg (837, 541) (988, 632) 0.99
103. Jpg (1552, 168) (1705, 245) 0.93
104. Jpg (1556, 693) (1713, 776) 0.83
105. Jpg (869, 258) (1018, 355) 0.96
106. Jpg (1559, 212) (1722, 284) 0.80
107. Jpg (873, 83) (1023, 182) 0.99
109. Jpg (1604, 277) (1756, 353) 0.89
110. Jpg (956, 726) (1105, 825) 0.99
110. Jpg (1596, 784) (1751, 863) 0.90
112. Jpg (963, 503) (1106, 595) 0.99
112. Jpg (1614, 301) (1757, 382) 0.91
I need more than 1200 in the second column number and the line to delete it, and keep the rest of the
The output is like this:
1. Jpg (829, 792) (976, 888) 0.99
10. Jpg (843, 651) (993, 750) 0.99
101. Jpg (819, 655) (967, 754) 0.99
103. Jpg (837, 541) (988, 632) 0.99
105. Jpg (869, 258) (1018, 355) 0.96
107. Jpg (873, 83) (1023, 182) 0.99
110. Jpg (956, 726) (1105, 825) 0.99
112. Jpg (963, 503) (1106, 595) 0.99

CodePudding user response:

Line by line read
With a whitespace-delimited string
To replace the brackets
A comma separated string
Into digital
Compare the size
Will be eligible to save to a new folder

CodePudding user response:

Readline after read line by line, replace) for replacement (", "use the split again for the parts, but note that one of two commas is empty, again according to your condition judgment, written to another file

CodePudding user response:

references on 1st floor day I reply:

read line by lineWith a whitespace-delimited string
To replace the brackets
A comma separated string
Into digital
Compare the size
Will be eligible to save to a new folder

Good to know, thank you

CodePudding user response:

refer to the second floor weixin_45903952 response:
readline after read line by line, replace) for replacement (", "use the split again for the parts, but note that one of two commas is empty, again according to your condition judgment, written to another file

Good to know, thank you
  • Related