diff cmpb2016/appending.py @ 0:8be019b173e6 draft

Uploaded included tools
author chmaramis
date Sun, 18 Mar 2018 05:54:20 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cmpb2016/appending.py	Sun Mar 18 05:54:20 2018 -0400
@@ -0,0 +1,43 @@
+# -*- coding: utf-8 -*-
+"""
+Created on Wed Nov 05 14:17:24 2014
+
+@author: chmaramis
+"""
+
+import numpy as np
+from pandas import *
+from numpy import nan as NA
+import sys
+import time
+
+def appending(arg):
+
+    appfr = DataFrame()
+    for path in arg:
+        frame = DataFrame()
+        tp = read_csv(path, iterator=True, chunksize=1000,sep='\t', index_col=0 )
+        frame = concat([chunk for chunk in tp])
+        appfr = appfr.append(frame)
+    appfr = appfr[frame.columns]
+    appfr.index = range(1,len(appfr)+1)
+    return appfr
+
+if __name__ == '__main__':   
+
+    start=time.time()
+
+    # Parse input arguments    
+    arg=sys.argv[2:]
+    lastEl = sys.argv[1]
+            
+    # Execute basic function
+    appfr = appending(arg)
+    
+    # Save output to CSV files
+    if not appfr.empty:        
+        appfr.to_csv(lastEl, sep= '\t')
+        
+    # Print execution time
+    stop=time.time()
+    print('Runtime:' + str(stop-start))