Mercurial > repos > mb2013 > naturalis_internship
changeset 4:6f86f68d2904 draft default tip
Deleted selected files
author | mb2013 |
---|---|
date | Mon, 19 May 2014 07:51:15 -0400 |
parents | 1484ee3d947d |
children | |
files | convert_multiple_dta_to_csv.py convert_multiple_dta_to_csv.xml |
diffstat | 2 files changed, 0 insertions(+), 74 deletions(-) [+] |
line wrap: on
line diff
--- a/convert_multiple_dta_to_csv.py Wed Nov 20 03:54:05 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -#Converter of multiple dta files to one csv -#M.Baak -#13-11-2013 -#last update: 13-11-2013 - -import sys -import os - - -file_outputname = sys.argv[1] -file_outputname2 = sys.argv[2] -file_name = sys.argv[3:] - -def convert_dta(file_name,file_outputname,file_outputname2): - output = open(file_outputname,'w') #output file - output2 = open(file_outputname2, 'w') - - for x in range(0,len(file_name)): - read_file = open(file_name[x], 'r') #open file - a = len(read_file.readlines()) - read_file2 = open(file_name[x], 'r') # open file second time - - - numberlandmarks = 0 - header = "" - - #for loop, coordinates, number of landmarks and name of sample will be stored in csv format - for x in range(0,a): - b = read_file2.readline().strip() - split_tabs = b.split(' ') - number_columns = len(split_tabs) - if x == 0: - header += b.replace(' ', '_') #name of sample - if number_columns == 3: #coordinates - output.write("%f,%f,%f\n"%(float(split_tabs[0]),float(split_tabs[1]),float(split_tabs[2]))) - numberlandmarks += 1 # number of landmarks - - output2.write("%s\n"%(header[1:-4])) # writing header to output file - - output.close() - -convert_dta(file_name,file_outputname,file_outputname2) - - - -
--- a/convert_multiple_dta_to_csv.xml Wed Nov 20 03:54:05 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ -<tool id="dtaConverter2" name="dtaConverter2"> - <description>convert multiple dta files to one csv file</description> - <command interpreter="python"> - convert_multiple_dta_to_csv.py - $output - $output2 - $input1 - #for $q in $queries - ${q.input2} - #end for - </command> - <inputs> - <param name="input1" type="data" label="Convert dta"/> - <repeat name="queries" title="Dataset"> - <param name="input2" type="data" label="Select" /> - </repeat> - </inputs> - <outputs> - <data format="csv" name="output" /> - <data format="csv" name="output2" /> - </outputs> - - - <help> -convert dta to csv - </help> - -</tool>