Repository 'tabular_to_csv'
hg clone https://toolshed.g2.bx.psu.edu/repos/mnhn65mo/tabular_to_csv

Changeset 0:659820e2aa61 (2018-08-08)
Next changeset 1:f1b7d0032530 (2018-09-11)
Commit message:
Uploaded
added:
tab2csv.R
tab2csv.xml
b
diff -r 000000000000 -r 659820e2aa61 tab2csv.R
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tab2csv.R Wed Aug 08 06:23:04 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"){
+    tabular<-read.table(args[1],sep="\t",header=TRUE)
+    write.tale(tabular,"out.csv",sep=args[2],row.names=FALSE)
+}else{
+    tabular<-read.table(args[1],sep="\t",header=FALSE)
+    write.table(tabular,"out.csv",sep=args[2],col.names=FALSE,row.names=FALSE)
+}
+
b
diff -r 000000000000 -r 659820e2aa61 tab2csv.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tab2csv.xml Wed Aug 08 06:23:04 2018 -0400
[
@@ -0,0 +1,73 @@
+<tool id="tab2csv_R" name="Tabular to CSV" version="0.1">
+    <requirements>
+        <requirement type="package" version="3.2.1">R</requirement>
+    </requirements>
+    <command detect_errors="exit_code"><![CDATA[
+        Rscript '$__tool_directory__/tab2csv.R' '$input1' '$sep' '$header' '$output' ]]>
+    </command>
+    <inputs>
+        <param format="tabular" name="input1" type="data" label="tabular file"/>
+        <param name="sep" type="text" label="output csv 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="csv" name="output" from_work_dir="out.csv" />
+    </outputs>
+    
+    <tests>
+        <test>
+            <param name="input1" value="example_tab.tabular"/>
+            <param name="sep" value=","/>
+            <param name="header" value="FALSE"/>
+            <output name="output" file="out.csv"/>
+        </test>
+    </tests>
+
+    <help>
+**What it does**
+
+Convert a tabular file to a CSV.
+
+Transform the tabs to the chosen separator. It is important to specify if the file has a header line.
+
+------
+
+**Example**
+
+Input tabular :
+
+ "John" "Smith" "2 mySteet, myCity"
+
+ "François" "LeFrançais" "1 rue du Général, Paris"
+
+ "Other" "Random" "Stuff, stuff, stuff"
+
+
+Output CSV :
+
+ "John","Smith","2 mySteet, myCity"
+
+ "François","LeFrançais","1 rue du Général, Paris"
+
+ "Other","Random","Stuff, stuff, stuff"
+
+
+
+
+------
+
+**Arguments**
+
+Input : tabular file.
+
+Separator : default is ",".
+
+Header : True/False.
+
+
+    </help>
+</tool>