GitMurf / csv-to-roam-table-md

Prepare/convert your CSV tables to be ready to import into your Roam Research database.
MIT License
8 stars 1 forks source link

Create pages with attributes from CSV #17

Closed GitMurf closed 4 years ago

GitMurf commented 4 years ago

@phhq and @classicrob I am ready for the first ROUGH test. I created a variable at the top of the script: $bTesting = $true which puts it in "Test Mode" which basically just means that I append "TESTING_" in front of every page name so that it is simple to go find the pages created and delete them. If you want to actually put the script into action with some of your real data (which I caution you at this point without more testing) you simply just change it to $bTesting = $false

Get the most recent version from this link below. Make sure the "Branch" is set to the "create-pages-with-attributes" and NOT the "master" branch as that doesnt have my stuff merged until we do some testing and get your feedback. In the Resources folder I have 2 simple .csv that i was using to test with if you want to use those.

https://github.com/GitMurf/csv-to-roam-table-md/tree/create-pages-with-attributes

Give it a try and let me know! Still have a bunch of items to add/tweak but I think have the basic principle down.

Video Demo: https://www.screencast.com/t/xEq45WGWkl

GitMurf commented 4 years ago

Things to fix

Running list:

GitMurf commented 4 years ago

Things To Add

Running list:

GitMurf commented 4 years ago

I just recorded a 25 minute demo of the script and several examples...

https://www.screencast.com/t/xEq45WGWkl

GitMurf commented 4 years ago

AuJQu0juln

GitMurf commented 4 years ago

Bug with Roam with importing indented Attribute:: items/pages. See my Issue raised with Roam here: https://github.com/Roam-Research/issues/issues/41

GitMurf commented 4 years ago

Bug with Roam with importing indented Attribute:: items/pages. See my Issue raised with Roam here: Roam-Research/issues#41

Here is a workaround, while not ideal, to the issue. I have to add a space between the colons before import and then just remove the space so it then becomes an attribute in Roam without creating the issue where it include the Indent and Bullet in the attribute name.

5MghYCIWv4

For @phhq your use case of invalid windows characters for filename and preserving it by not creating a markdown file for Import with my script but instead just going in after you import the script results and go to the summary page and for just the pages with invalid characters nested under them are their attributes so you can simply then copy/paste to its Page. But because of Roam bug I mentioned earlier today, the workaround is I create the attribute with a space between colons like Attribute: : Value1 so it won't be imported as an attribute but you simply just need to remove the space from inbetween the 2 colons and then it will become attribute and you can move the bullets to the root of the Page created that had the invalid windows name.... not ideal but at least working for now until Roam fixed attribute bug. Make sense? What do you think?

GitMurf commented 4 years ago

sdf

GitMurf commented 4 years ago

Pasting in my explanation to EA (@phhq) in Slack DM explaining the Roam bug for importing Attributes:: that are NOT in root of page and what it means to my script and the workaround(s):

https://roamresearch.slack.com/archives/D0123LVFSMD/p1588185847110300

11:32 AM EA But this is really only an issue for the summary page, right? Because on the indvidual pages each page's attributes are in the root level correct? (edited) 11:33 AM Murf For my script this only matters when a Page Name will have the illegal windows characters in it (like | or / or : etc.) because my workaround was to not create a .MD file for those pages because would require replacing those characters and changing what you want overall like you mentioned. So instead the page gets created my the backlink in the summary page when it is imported and then you can add the attributes to it quickly like in my GIF above. But for now then have the annoying : : attribute bug that you just have to manually fix for just those pages with illegal names. 11:33 AM EA I see. 11:34 AM so better to make sure all of the page names in the csv do not have illegal characters, before processing the csv -- 11:34 AM Murf so yes to your question. Only effects on summary page but even for that, it only effects the pages that have illegal characters in their name because if normal page name then I dont add the attributes on the summary page. make sense? 11:35 AM well not necessarily... we can still use page names you want in the CSV with illegal characters... just have to do the few extra manual steps of the attribute : : deleting the space and then drag under the page name when in Roam. 11:36 AM assuming you dont have 100's of page names with illegal characters and that it is the "corner case" then it isn't a big deal to have to manually update a few in Roam. I mean if you are updating in CSV then you may as well get exactly what you want and instead just spend that time updating in Roam. 11:37 AM So basically, if you have no illegal windows characters in your first column of CSV (which will create Pages) then the bug above has zero effect because don't put the attributes on the summary page and they are put in the Root of the Page created because we create the .MD file from the script and import it with the summary page. 11:44 AM Murf The only except is any pages with illegal characters. But I have the script now preserving the page names with illegal characters exactly how you would want because for just those illegal pages, the script will NOT create a .MD file to import. The page will still get created automatically in Roam due to the Backlink from the summary page (which is great) and it will be with the illegal characters exactly how you wanted it from the CSV... you just need to take the extra step of then dragging/cutting/pasting the attributes for each of those illegal character pages from the Summary page to the actual Page created. That in itself isn't too hard at all especially if you open Summary page in sidebar and then click each new page name from summary page sidebar to open in main Roam page and then simply drag the attributes from sidebar summary page, to the main page. BUT where the attribute bug comes into play (which i assume will be fixed soon... hopefully) is that once you drag the attributes to your Page, you need to delete the extra space I added between the two colons for the attributes : : so that it then officially validates/confirms the attribute and will create/link it correctly. Because the problem is that Roam has a bug where when importing it appears to validate/set the attribute BEFORE it goes through import logic of formatting indents and bullet locations... so it essentially creates/validates the attribute as attribute:: ... instead of interpreting the as setting up the hierarchy/location of that block and then validating/creating/setting the attribute as attribute::. So it is essentially creating an attribute page called "attribute"

GitMurf commented 4 years ago

25 Just got the Json vs markdown option and attribute vs block import implemented and ready to merge to master.