|
0
|
1 # -*- coding: utf-8 -*-
|
|
|
2 """
|
|
|
3 Created on Wed Nov 05 14:17:24 2014
|
|
|
4
|
|
|
5 @author: chmaramis
|
|
|
6 """
|
|
|
7
|
|
|
8 import numpy as np
|
|
|
9 from pandas import *
|
|
|
10 from numpy import nan as NA
|
|
|
11 import sys
|
|
|
12 import time
|
|
|
13
|
|
|
14 def appending(arg):
|
|
|
15
|
|
|
16 appfr = DataFrame()
|
|
|
17 for path in arg:
|
|
|
18 frame = DataFrame()
|
|
|
19 tp = read_csv(path, iterator=True, chunksize=1000,sep='\t', index_col=0 )
|
|
|
20 frame = concat([chunk for chunk in tp])
|
|
|
21 appfr = appfr.append(frame)
|
|
|
22 appfr = appfr[frame.columns]
|
|
|
23 appfr.index = range(1,len(appfr)+1)
|
|
|
24 return appfr
|
|
|
25
|
|
|
26 if __name__ == '__main__':
|
|
|
27
|
|
|
28 start=time.time()
|
|
|
29
|
|
|
30 # Parse input arguments
|
|
|
31 arg=sys.argv[2:]
|
|
|
32 lastEl = sys.argv[1]
|
|
|
33
|
|
|
34 # Execute basic function
|
|
|
35 appfr = appending(arg)
|
|
|
36
|
|
|
37 # Save output to CSV files
|
|
|
38 if not appfr.empty:
|
|
|
39 appfr.to_csv(lastEl, sep= '\t')
|
|
|
40
|
|
|
41 # Print execution time
|
|
|
42 stop=time.time()
|
|
|
43 print('Runtime:' + str(stop-start))
|