Editorial Workflows

csv_to_md_table

public workflow

Install Workflow...

This workflow contains at least one Python script. Only use it if you trust the person who shared this with you, and if you know exactly what it does.

I understand, install the workflow!

This is a workflow for Editorial, a Markdown and plain text editor for iOS. To download it, you need to view this page on a device that has the app installed.

Description: A workflow for converting csv tables --> markdown tables --> HTML tables with borders --> PDF.

Shared by: @cclauss

Comments: Comment Feed (RSS)

There are no comments yet.

+ Add Comment

Workflow Preview
Selected Text ?
Entire Line(s)
OFF
Empty Selection Output
  • No Output
  • All Text
  • Closest Word
Folded Text
  • Include
  • Replace with:
csv_to_md_table ?
Source Code
# coding: utf-8
import csv
import workflow


def md_table_row(row):
    return '| {} |'.format(' | '.join(row))


def csv_to_md_table(data):
    assert data.strip(), 'Select some csv data to be converted.'
    rows = []
    for i, row in enumerate(csv.reader(x.rstrip(',') for x in data.splitlines()
                                       if x.rstrip(','))):
        rows.append(md_table_row(row))
        if i == 0:
            rows.append(md_table_row('---' for cell in row))
    return '\n'.join(rows)


workflow.set_output(csv_to_md_table(workflow.get_input()))
Convert Markdown ?
Markdown Extras: Footnotes
ON
…Auto-Links
ON
…Strikethrough (~~x~~)
ON
…Superscript (^x)
ON
…Tables
ON
…Smart Quotes etc.
ON
…Strip Metadata Headers
OFF
Add border to HTML table ?
Source Code
#coding: utf-8
import workflow
workflow.set_output(workflow.get_input().replace('<table>', '<table border=1>'))
Generate PDF Document ?
Source
  • HTML Code
  • Web URL
HTML/URL
Input
Paper Size
  • A4
  • Letter
Page Margins
2cm 2.5cm 2cm 2.5cm
Filename
Table.pdf
in Dropbox
OFF
Overwrite
ON
Open Document ?
File Name
Table.pdf
In Dropbox
OFF