Advertisement
atm-irbis

lines 2

Apr 8th, 2013
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. import os
  2.  
  3. def line_trim(s):
  4.     return s.split()[0]
  5.  
  6. dir = '/home/caveat/tmp/'
  7. flist = os.listdir(dir)
  8. for i in flist:
  9.     fullname = os.path.join(dir,i)
  10.     if os.path.isfile(fullname) and not i.endswith('.txt'):
  11.         f = open(fullname,'r')
  12.         np = fullname + '.txt'
  13.         g = open(np,'w')
  14.         for j in f.readlines():
  15.             g.write(line_trim(j)+'\n')
  16.         g.close()
  17.         f.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement