Mercurial > repos > chmaramis > testirprofiler
comparison cmpb2016/appending.py @ 0:8be019b173e6 draft
Uploaded included tools
| author | chmaramis |
|---|---|
| date | Sun, 18 Mar 2018 05:54:20 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:8be019b173e6 |
|---|---|
| 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)) |
