def concatcsv(in_files):
 import os.path as op
 from nipype.utils.filemanip import split_filename
 if (not isinstance(in_files, list)):
  return in_files
 if isinstance(in_files[0], list):
  in_files = in_files[0]
 first = open(in_files[0], u'r')
 (path, name, ext) = split_filename(in_files[0])
 out_name = op.abspath(u'concat.csv')
 out_file = open(out_name, u'w')
 out_file.write(first.readline())
 first.close()
 for in_file in in_files:
  file_to_read = open(in_file, u'r')
  scrap_first_line = file_to_read.readline()
  for line in file_to_read:
   out_file.write(line)
 return out_name

def concatcsv ( in_files ) : import os . path as op from nipype . utils . filemanip import split_filename if ( not isinstance ( in_files , list ) ) : return in_files if isinstance ( in_files [ 0 ] , list ) : in_files = in_files [ 0 ] first = open ( in_files [ 0 ] , u'r' ) ( path , name , ext ) = split_filename ( in_files [ 0 ] ) out_name = op . abspath ( u'concat.csv' ) out_file = open ( out_name , u'w' ) out_file . write ( first . readline ( ) ) first . close ( ) for in_file in in_files : file_to_read = open ( in_file , u'r' ) scrap_first_line = file_to_read . readline ( ) for line in file_to_read : out_file . write ( line ) return out_name
this function will contatenate two "comma-separated value" text files .