Python Application 2 – Extract File Content

 
Step 1
 
Open any text editor (gedit,pico,vi,nano) then enter the following python script and save the file with .py extension.
 
#!/usr/bin/python
#Author : Jijo K Jose
 
f1 = open("logfile","r")
 
for i in f1.readlines():
 j = i.split(' ')
 print j
 
#END

 
The logfile contents are
 
25% [========>] 1,67,51,728 9.87K/s eta 2h 1m 
25% [========>] 1,67,56,078 9.88K/s eta 2h 1m 
25% [========>] 1,67,60,428 10.2K/s eta 2h 1m 
25% [========>] 1,67,64,778 9.71K/s eta 2h 1m 
25% [========>] 1,67,70,578 10.0K/s eta 2h 1m 
25% [========>] 1,67,76,378 10.3K/s eta 2h 1m 
25% [========>] 1,67,82,178 10.4K/s eta 2h 1m 
25% [========>] 1,67,87,978 12.3K/s eta 2h 1m 
25% [========>] 1,67,93,778 12.0K/s eta 2h 1m 
 
Step 2
 
Change file permission to executable using chmod command.
 
Step 3
 
Execute the python file.
 
python-application-extract-text-content
 

 
You can leave a response, or trackback from your own site.

Leave a Reply