1. test2.py:
2. ==========
3.
4. #!/usr/bin/env python
5. # -*- coding: UTF-8 -*-
6. #
7.
8. from csv import reader, writer
9.
10. outs = dict((s, writer(open('ma in442-' + s, 'w'), delimiter='|')) for s in ['2.1.4'])
11. for row in reader(open('cl i1.txt'), delimiter='|'):
12. if row[6] in outs:
13. outs[row[6]].writerow([row[1]])
14.
15. clil.txt file:
16. =============
17. Username|Host|C onnected|Idleti me|ECM|EMM|Vers ion|Lastusedsha re
18. torremolinos|81 .192.41.180|00d 00:09:33|00d00: 09:33|0(0)|53(5 3)|2.1.3
19. hellas|94.71.73 .123|00d00:09:3 2|00d00:00:03|5 1(0)|0(0)|2.1.4 |0604:000000:01 6f(nok)
20. dreamhamdi|196. 213.44.122|00d0 0:09:30|00d00:0 7:18|1(0)|55(55 )|2.1.4|0500:04 2400:0325(nok)
21. dreamnaim|41.21 0.77.177|00d00: 09:24|00d00:09: 24|0(0)|0(0)|2. 1.3
22. dream11|41.226. 213.103|00d00:0 9:24|00d00:09:2 4|0(0)|0(0)|2.1 .3
23. dreamsadia|41.2 16.40.223|00d00 :09:24|00d00:09 :24|0(0)|0(0)|2 .1.3
24. dream15|41.216. 28.146|00d00:09 :24|00d00:09:24 |0(0)|0(0)|2.1. 4
25. dream14|41.216. 198.205|00d00:0 9:24|00d00:09:2 4|0(0)|0(0)|2.1 .3
26. dreaml4|95.114. 241.235|00d00:0 9:24|00d00:09:2 4|0(0)|0(0)|2.0 .9
27.
28. output :
29. ============
30. 41.226.253.199
31. 41.230.105.126
32. 94.71.73.113
33. 196.203.44.122
34. 41.226.28.146
35. 41.201.192.98
36. 41.248.47.28
this was working but i need ip address (second column ) with out search condition for example above program i entered '2.1.4' search term in 7th column
2. ==========
3.
4. #!/usr/bin/env python
5. # -*- coding: UTF-8 -*-
6. #
7.
8. from csv import reader, writer
9.
10. outs = dict((s, writer(open('ma in442-' + s, 'w'), delimiter='|')) for s in ['2.1.4'])
11. for row in reader(open('cl i1.txt'), delimiter='|'):
12. if row[6] in outs:
13. outs[row[6]].writerow([row[1]])
14.
15. clil.txt file:
16. =============
17. Username|Host|C onnected|Idleti me|ECM|EMM|Vers ion|Lastusedsha re
18. torremolinos|81 .192.41.180|00d 00:09:33|00d00: 09:33|0(0)|53(5 3)|2.1.3
19. hellas|94.71.73 .123|00d00:09:3 2|00d00:00:03|5 1(0)|0(0)|2.1.4 |0604:000000:01 6f(nok)
20. dreamhamdi|196. 213.44.122|00d0 0:09:30|00d00:0 7:18|1(0)|55(55 )|2.1.4|0500:04 2400:0325(nok)
21. dreamnaim|41.21 0.77.177|00d00: 09:24|00d00:09: 24|0(0)|0(0)|2. 1.3
22. dream11|41.226. 213.103|00d00:0 9:24|00d00:09:2 4|0(0)|0(0)|2.1 .3
23. dreamsadia|41.2 16.40.223|00d00 :09:24|00d00:09 :24|0(0)|0(0)|2 .1.3
24. dream15|41.216. 28.146|00d00:09 :24|00d00:09:24 |0(0)|0(0)|2.1. 4
25. dream14|41.216. 198.205|00d00:0 9:24|00d00:09:2 4|0(0)|0(0)|2.1 .3
26. dreaml4|95.114. 241.235|00d00:0 9:24|00d00:09:2 4|0(0)|0(0)|2.0 .9
27.
28. output :
29. ============
30. 41.226.253.199
31. 41.230.105.126
32. 94.71.73.113
33. 196.203.44.122
34. 41.226.28.146
35. 41.201.192.98
36. 41.248.47.28
this was working but i need ip address (second column ) with out search condition for example above program i entered '2.1.4' search term in 7th column
Comment