Mercurial > repos > mnhn65mo > csv_to_tabular
changeset 0:b735ac78702b draft default tip
Uploaded
author | mnhn65mo |
---|---|
date | Wed, 08 Aug 2018 06:19:35 -0400 |
parents | |
children | |
files | csv2tab.R csv2tab.xml |
diffstat | 2 files changed, 87 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/csv2tab.R Wed Aug 08 06:19:35 2018 -0400 @@ -0,0 +1,14 @@ +#!/usr/bin/env Rscript +#Read csv - return tabular +#2 Options for now : sep an header + +args = commandArgs(trailingOnly=TRUE) + +if(args[3]=="TRUE"){ + csv<-read.csv(args[1],sep=args[2],header=TRUE) + write.table(csv,"out.tabular",sep="\t",row.names=FALSE) +}else{ + csv<-read.csv(args[1],sep=args[2],header=FALSE) + write.table(csv,"out.tabular",sep="\t",col.names=FALSE,row.names=FALSE) +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/csv2tab.xml Wed Aug 08 06:19:35 2018 -0400 @@ -0,0 +1,73 @@ +<tool id="csv2tab_R" name="CSV to Tabular" version="0.1"> + <requirements> + <requirement type="package" version="3.2.1">R</requirement> + </requirements> + <command detect_errors="exit_code"><![CDATA[ + Rscript '$__tool_directory__/csv2tab.R' '$input1' '$sep' '$header' '$output' ]]> + </command> + <inputs> + <param format="csv" name="input1" type="data" label="CSV file"/> + <param name="sep" type="text" label="Separator" value=","> + <sanitizer sanitize="False"/> + </param> + <param name="header" type="boolean" truevalue="TRUE" falsevalue="FALSE" checked="true" label="Header in file"/> + + </inputs> + + <outputs> + <data format="tabular" name="output" from_work_dir="out.tabular" /> + </outputs> + + <tests> + <test> + <param name="input1" value="example_csv.csv"/> + <param name="sep" value=","/> + <param name="header" value="FALSE"/> + <output name="output" file="out.tabular"/> + </test> + </tests> + + <help> +**What it does** + +Convert a CSV file to a tabular. + +Transform the chosen separator to tab. It is important to specify if the file has a header line. + +If the field separator is a comma and there are commas inside text fields the tool will only modify the first category in tabs. + +------ + +**Example** + +Input CSV : + + "John","Smith","2 mySteet, myCity" + + "François","LeFrançais","1 rue du Général, Paris" + + "Other","Random","Stuff, stuff, stuff" + + + +Output tabular : + + "John" "Smith" "2 mySteet, myCity" + + "François" "LeFrançais" "1 rue du Général, Paris" + + "Other" "Random" "Stuff, stuff, stuff" + +------ + +**Arguments** + +Input : csv file. + +Separator : default is ",". + +Header : True/False. + + + </help> +</tool>