tsv2markdown¶
Often I’ve found myself having to add the contents of TSV (or CSV) files in markdown documents such as jupyter notebooks or rmarkdown documents. The process is very tedious, so I created a super simple script to output the contents so it could just be pasted into these documents.
CLI help message¶
A simple script to convert tsv (or csv) files to markdown tables using tabulate!
Copyright (C) 2020 Felipe Marques de Almeida (almeidafmarques@gmail.com)
License: Public Domain
usage:
falmeida-py tsv2markdown
falmeida-py tsv2markdown [ -h|--help ]
falmeida-py tsv2markdown [ --tsv <file> --csv <file> --header <list> ]
options:
-h --help Show this screen.
--tsv=<file> Input tsv file to print as markdown table
--csv=<file> Input csv file to print as markdown table
--header=<list> If file does not have a header, set a
custom header. E.g. --header "Planet,R (km),mass (x 10^29 kg)".
falmeida-py: a package to the simple distribution of my custom scripts.
Copyright (C) 2020 Felipe Marques de Almeida (almeidafmarques@gmail.com)
License: Public Domain
usage:
falmeida-py [ -h|--help ] [ -v|--version ] [ --license ]
falmeida-py <command> [ -h|--help ] [ <args>... ]
options:
-h --help Show this screen
-v --version Show version information
--license Show LEGAL LICENSE information
commands:
tsv2markdown Command for rapid convertion of tsv or csv to markdown tables.
splitgbk Command to split multisequence genbank files into individual files.
align2subsetgbk Command to subset genbank files based on alignments to a FASTA file.
gbk2fasta Command to convert genbank files to fasta files.
blasts Command to execute automatized blast commands.
replace_fasta_seq Command to replace strings in a FASTA using defitinitions from a BED file
mpgap2csv Command to summarize main mpgap multiqc assembly statistics into a CSV file
bacannot2json Command to summarize main bacannot annotation results into JSON file
Use: `falmeida-py <commmand> -h` to get more help and see examples.
Usage¶
The usage is super simple. For example, given the following CSV:
sample1,brazil,river,2020
sample2,argentina,sewer,2020
sample3,brazil,sewer,2020
We could rapidply create a markdown table entry with:
falmeida-py tsv2markdown --csv sample.csv --header "sample id,country,collection source,year"
| sample id | country | collection source | year |
|-------------|-----------|---------------------|--------|
| sample1 | brazil | river | 2020 |
| sample2 | argentina | sewer | 2020 |
| sample3 | brazil | sewer | 2020 |
Note
If the first line of the document (TSV or CSV) is a header, will to not need to use the --header
option, because it will use the frist line as the header.