Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello β I'm @olemoritz on Twitter.
CSV to mmd table
-
That's part of the problem, at least.
Here is a test version, instead of my spreadsheet of goals... it is more consistent by far... but it still isn't creating a table correctly. :-/
CLIENT'S SHORT-TERM BEHAVIORAL GOALS,THERAPIST'S INTERVENTIONS,,,,,
Some goal to accomplish something. Someone's got to do something. Just sayin'.,Try everything and do what works. Because something has got to get better sometime. ,,,,,
Some goal to accomplish something. Someone's got to do something. Just sayin'.,Try everything and do what works. Because something has got to get better sometime. ,,,,,
Some goal to accomplish something. Someone's got to do something. Just sayin'.,Try everything and do what works. Because something has got to get better sometime. ,,,,,
Some goal to accomplish something. Someone's got to do something. Just sayin'.,Try everything and do what works. Because something has got to get better sometime. ,,,,,
Some goal to accomplish something. Someone's got to do something. Just sayin'.,Try everything and do what works. Because something has got to get better sometime. ,,,,, -
It might be helpful to simplify your data initially so you can see the forest from the trees... Consider this Numbers CSV export:
A,B,C,D,E,F 0,1,2,3,4,5 a,b,c,d,e,f ,,,,, ,,,,, ,,,,,
CSVs are not rocket science as long as your data (in each cell) does not include commas or quotes. If commas and quotes are present Numbers and the Python CSV module will do a pretty good job of properly escaping them in consistent ways.
With a simpler dataset, can you demonstrate where the Tabify workflow is doing the wrong thing?
-
@ccc Simplifying would be fantastic. I have all of these treatment plans already written up for a variety of diagnoses in word files as tables. So, to simplify, I might as well rewrite them anyways... which I (really) don't want to do. I have about 10-12 treatment plans I use on a regular basis, but 30 or so treatment plans I would need to rewrite to simplify.
I copy and pasted them into numbers and then exported to CSV.
I am not sure how to make this work in a simple, not effort intensive fashion.
Think. Think. Think.
-
Here is something simpler:
Some data here,Some data there,,,,,
Do something.,Try something else,,,,,
Do a.,Try something a,,,,,
Do b.,Try something b,,,,,
Do c.,Try something c,,,,,
Do d.,Try something d,,,,,
Do e.,Try something e,,,,,Produces:
(Even if the 5 commas are shortened first to 1 comma... had to replace some text... got flagged as spam?)''' Some data here,Some data there, Do something.,Try something else, Do something.,Try something else, Do something.,Try something else, Do something.,Try something else, Do something.,Try something else, Do something.,Try something else, Do something.,Try something else, Do something.,Try something else, Do something.,Try something else, Do something.,Try something else, ''' -
Perfect. I will work up something.
-
I did find a workaround of sorts... I can copy and paste the table into tablesgenerator.com, which converts nicely, even with all of the potential issues.
I have one final issue on this front. I need this table to have some kind of visible borders when converted to PDF. Currently the PDF converter shows no borders for mmd tables. Ideas?
-
Workflow: csv_to_md_table http://www.editorial-workflows.com/workflow/5903925597175808/9VyhSkEy50k
# 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(('---', '\n'.join(rows), '---')) workflow.set_output(csv_to_md_table(workflow.get_input()))
-
That did a much better job of creating the table... 2 things... I need grid lines the be throughout the table. It's not very readable without that. I thought about trying to make the table into two numbered lists, so each line could be matched that way. But it would be much easier if it could be matched visually with grid lines or thin lines between each row.
I also need it to be part of the overall final report in PDF, not a file by itself... I could just take out the last action in the workflow, I think to get the md table, but then I wouldn't be able to set it up to have the borders/grid... any ideas?
I've finished the first version of this process and am starting to write these reports today. We'll see how it goes.
-
Borders are easy... You add them at the HTML step...
workflow.set_output(workflow.get_input().replace('<table>', '<table border=1>'))
See updates at http://www.editorial-workflows.com/workflow/5903925597175808/9VyhSkEy50k
-
And soooooooo.....
Here is a workflow for this step of my process. http://www.editorial-workflows.com/workflow/5771846762889216/xI4LXsctvGg
The csv is exported from iOS Numbers into editorial. This workflow takes the file contents of that csv (which is default named Blank.csv) and converts it to a mmd table, adds borders in the HTML step. Replaces the csv text with the mmd table... and in the shared workflow outputs to a PDF file. I'll save that step until I'm done with the whole report.
All python thanks to @ccc , who is effing fantastic.
ππ»πΊπΌπ₯πβ¨π«πΎπ₯πππ