def sep2tabs(fname, in_place=True, patt='\\s+'):
 regexp = re.compile(patt)
 (fd, temp_name) = tempfile.mkstemp()
 fp = os.fdopen(fd, 'wt')
 i = None
 for (i, line) in enumerate(open(fname)):
  line = line.rstrip('\r\n')
  elems = regexp.split(line)
  fp.write(('%s\n' % ' DCTB '.join(elems)))
 fp.close()
 if (i is None):
  i = 0
 else:
  i += 1
 if in_place:
  shutil.move(temp_name, fname)
  return (i, None)
 else:
  return (i, temp_name)

def sep2tabs ( fname , in_place = True , patt = '\\s+' ) : regexp = re . compile ( patt ) ( fd , temp_name ) = tempfile . mkstemp ( ) fp = os . fdopen ( fd , 'wt' ) i = None for ( i , line ) in enumerate ( open ( fname ) ) : line = line . rstrip ( '\r\n' ) elems = regexp . split ( line ) fp . write ( ( '%s\n' % ' DCTB ' . join ( elems ) ) ) fp . close ( ) if ( i is None ) : i = 0 else : i += 1 if in_place : shutil . move ( temp_name , fname ) return ( i , None ) else : return ( i , temp_name )
transforms in place a sep separated file to a tab separated one .