Giter Site home page Giter Site logo

notion-2-obsidan's Introduction

Notion-2-Obsidian

For those considering switching from Notion to Obsidian, here is a Python 3 script that converts your Notion export into an Obsidian friendly format.

When you run the N2O.py script, it will:

  1. Launch an Open-File dialogue where you'll navigate to your Notion-Export.zip file
  2. Convert all Internal Links in your Notion pages to an Obsidian friendly markdown format
  3. Repackages all the files into a new zip archive that is Obsidian vault compatible

The script will leave your orginal Notion archive unmodified.

The resulting archive can be extracted and opened as, or added to, an Obsidian vault.

The Problem with your Notion Export

Out of the box, the export files that Notion provides do not migrate to Obsidian very well. All external links will work, but:

  • The hierarchical structure of your pages can only be navigated using Obsidian’s file explorer.
  • None of the internal navigation links work, which also means there won’t be any backlinks or connections in Obsidian's Graph View.
  • None of the content in your Notion tables will be viewable.
  • Embedded images also won’t show.

All of this is remedied by this script. Note however, that Notion comments do NOT appear to be included in their export files.

Methodology

If you're interested, the full sequence of modifications needed to make your Notion export compatible with Obsidian can be found in the write-up found in the Methodology.md file in this git.

Supporting the Work

I’m happy to offer you this script and the conversion methodology. If you're able and inclined, a donation for the convenience and time savings would be genuinely appreciated. There's a couple donation links at the bottom of this page.

I estimate that anyone using the Methodology.md can convert their Notion export in a day or less of work. Without this guide, it would likely take several days of troubleshooting. If you’re a confident programmer, it may take you just a couple hours with the guide. I encourage everyone to go through the process. It is satisfying.

However, if your time is worth more spent elsewhere. Feel free to use the code and switch to Obsidian in mere seconds!

Export Your Full Notion Database

If you haven't already, you'll need to export your content from Notion.

  1. From your Notion app, click the Settings & Members tab in the sidebar
    Settings&Members
  2. Find and click the Settings tab. Find the Export content section. Click the Export all workspace content button
    Settings
  3. Select Markdown & CSV as Export Format and click the Export button
    Export
  4. Save the resulting .zip file to your computer
  5. Extract the .zip contents to a known location

Run the N2O.py Script

  • Make sure N2O.py and N2Omodule.py are in the same directory.
  • Run Python3 N2O.py
  • Use the Open-File dialog that pops up to navigate to your NotionExport.zip file.
  • When the script finishes you'll find a new zip file in the same directory that's ready for Obsidian.

Importing or Integrating into Obsidian

Time to import everything into Obsidian

  1. Place all the converted files into a directory of your choosing
  2. Open Obsidian and click the Vault Icon vault icon
  3. Select Open folder as vault
    open vault
  4. Use the Select Folder window to navigate to the directory with your newly converted files

Enjoy the shift to Obsidian!

Donation Links

If the instructions or code have been useful for you, please consider the time you've saved and treat me to half a lunch or so :) My hole-in-the-bucket Covid-19 era income would greatly appreciate it.

Here are some donation links for me:

notion-2-obsidan's People

Contributors

omegakid1902 avatar visualcurrent avatar zsrobinson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

notion-2-obsidan's Issues

Error 2

E:\Desktop Data\Downloads\Notion-2-Obsidan-master>python N2O.py
Traceback (most recent call last):
File "N2O.py", line 138, in
with open(newfilepath, 'wb') as f:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\owner\AppData\Local\Temp\tmppg9672w4\Untitled\Lime\Write Ups.html'

When I try to open my export zip seems to hit an error

Some links are broken

Thanks to last updates
a2af4a4
0fa820b
They fixed a lot of issues related to Cyrillic paths and names.

But I got some issues with links to files.
Some links are broken

  1. [[marketing images/Highlevel_Funnel_(6]].png) instead of [[marketing images/Highlevel_Funnel_(6).png]]
    [[marketing images/Untitled_Chart_(20]].png) and other examples with (N) in the name

  2. [Devid_Emocionalnaya-gibkost.fb2](%D0%9F%D0%BE%D0%B4%D0%B1%D0%BE%D1%80%D0%BA%D0%B0%20%D0%BC%D0%B0%D1%82%D0%B5%D1%80%D0%B8%D0%B0%D0%BB%D0%BE%D0%B2%20%D0%BF%D1%80%D0%BE%20%D1%8D%D0%BC%D0%BE%D1%86%D0%B8%D0%B8%20416b39ac03384f86b3be796f3c6ef6f2/Devid_Emocionalnaya-gibkost.fb2) instead of [[Подборка материалов про эмоции/Devid_Emocionalnaya-gibkost.fb2]] and similar problems with attachments like .pdf, .xlsx etc

  3. files with [] in the name [[Курс %5BStepik%5D/Screenshot_2021-03-28_at_14.57.49.png]] instead of [[Курс [Stepik]/Screenshot_2021-03-28_at_14.57.49.png]]

Implementation into Obsidian's Importer plugin

Hi @visualcurrent! Recently, the Obsidian team has started work on an official plugin called 'Importer', for importing notes from other applications, one of the proposed formats is Notion.

Since you've worked on this script and have extensive knowledge on how the syntax should be properly converted, I was wondering if you're interested in implementing the convertion logic into the plugin. There is a bounty attached to succesfully implementing the code within the provided timeframe (10 days) after assignment.

I've already applied for the assignment, but I'll withdraw it if you're interested in working on it.

Can't select zip

Hi,

I'm trying to operate your python script following the instructions at https://github.com/visualcurrent/Notion-2-Obsidan/blob/master/README.md

When I run "Python3 N2O.py", the open file dialog appears, but I can't select any zip files within it. All the files in the dialog are greyed out and cannot be selected.

image

Directories can be selected, but selecting them simply opens them - it doesn't launch your script.

Using a Mac.

If I manually edit N2O.py to hard-code the path to the zip, it seems to work:

NotionZip = Path("/path/to/my/notionexport.zip")

Thanks

Invalid Syntax

When I run the .py, I get a report back invalid syntax. I am using Python 3.9.

List Index out of Range

Hi,

Thanks for making this–we really appreciate it!

I am a long-time Notion user desperately trying to give Obsidian a try and wanted to test out what I’ve built so far using your converter.

Unfortunately, I run into this error. Any thoughts?

Traceback (most recent call last): File “C:/Users/adity/OneDrive/Desktop/Notion-2-Obsidan/N2O.py”, line 85, in mdTitle = N2Omodule.N2Ocsv(csvFile) File “C:\Users\adity\OneDrive\Desktop\Notion-2-Obsidan\N2Omodule.py”, line 68, in N2Ocsv IntLinks = list(dictionry.keys())[0] # Only want 1st column header IndexError: list index out of range

How do I make it work

I am on a windows machine, I am not much of a programmer. I don't know where to run the file, tried Windows Terminal, Python 3.8 from Microsoft Store, Anaconda Spyder, all give error somewhere

Bad work with Cyrillic symbols

Thanks for this useful script!

But it have some trouble with Cyrillic, can you fix this please? (

Given: folder with list of pages, some page have name with Cyrillic symbols

image

After applying script I have got this in folder page:

b'[[\xd0\x98\xd1\x81\xd1\x81\xd0\xbb\xd0\xb5\xd0\xb4\xd0\xbe\xd0\xb2\xd0\xb0\xd0\xbd\xd0\xb8\xd0\xb5 \xd0\xbd\xd0\xb0 \xd1\x82\xd0\xb5\xd0\xbc\xd1\x83 \xd0\xb2\xd0\xbe\xd0\xb7\xd0\xbc\xd0\xbe\xd0\xb6\xd0\xbd\xd1\x8b\xd1\x85 \xd0\xbf\xd1\x80\xd0\xbe\xd1\x84\xd0\xb5\xd1\x81\xd1\x81\xd0\xb8\xd0\xb9]]'
b'[[\xd0\x9e\xd0\xb1\xd0\xbc\xd0\xb0\xd0\xbd\xd0\xb8 \xd0\xb2\xd1\x81\xd0\xb5\xd1\x85 2 1]]'
b'[[\xd0\x98\xd0\xb4\xd0\xb5\xd1\x8f \xd0\xb4\xd0\xbb\xd1\x8f \xd0\xb7\xd0\xb8\xd0\xbc\xd0\xbd\xd0\xb5\xd0\xb9 \xd0\xb4\xd0\xb2\xd0\xb8\xd0\xb6\xd1\x83\xd1\x85\xd0\xb8]]'
b'[[\xd0\x98\xd0\xb4\xd0\xb5\xd1\x8f \xd0\xb4\xd0\xbb\xd1\x8f \xd0\xbe\xd1\x80\xd0\xb3\xd0\xb0\xd0\xbd\xd0\xb8\xd0\xb7\xd0\xb0\xd1\x86\xd0\xb8\xd0\xb8]]'
b'[[\xd0\x9f\xd0\xb5\xd1\x82\xd0\xb0\xd1\x80\xd0\xb4\xd1\x8b \xd0\xbd\xd0\xb0 \xd1\x81\xd0\xb0\xd0\xbc\xd0\xbe\xd0\xbb\xd1\x91\xd1\x82\xd0\xb8\xd0\xba\xd0\xb0\xd1\x85]]'
b'[[\xd0\x90\xd0\xbd\xd1\x82\xd0\xb8\xd0\xba\xd0\xb0\xd1\x84\xd0\xb5 FriendZone]]'
b'[[\xd0\xa1\xd0\xbb\xd0\xb5\xd1\x82\xd0\xb0\xd1\x82\xd1\x8c \xd0\xb2 \xd0\xaf\xd0\xbf\xd0\xbe\xd0\xbd\xd0\xb8\xd1\x8e \xd0\xb2 \xd0\xbf\xd0\xb5\xd1\x80\xd0\xb8\xd0\xbe\xd0\xb4 \xd1\x86\xd0\xb2\xd0\xb5\xd1\x82\xd0\xb5\xd0\xbd\xd0\xb8\xd1\x8f \xd1\x81\xd0\xb0\xd0\xba\xd1\x83\xd1\x80\xd1\x8b]]'

What the decoder gave me (urlencoded -> UTF-8):
http://www.online-decoder.com/

b'[[Исследование на тему возможных профессий]]'
b'[[Обмани всех 2 1]]'
b'[[Идея для зимней движухи]]'
b'[[Идея для организации]]'
b'[[Петарды на самолётиках]]'
b'[[Антикафе FriendZone]]'
b'[[Слетать в Японию в период цветения сакуры]]' 

But files in folder have normal names:

image

Also:

Path to image in page contain urlencoded name of page so path is broken. If I delete this and left only image name, image is showing correct.

image

%D0%9C%D1%83%D0%B6%D1%81%D0%BA%D0%B0%D1%8F %D1%87%D0%B5%D1%80%D0%BD%D0%B0%D1%8F %D1%82%D0%BE%D0%BB%D1%81%D1%82%D0%BE%D0%B2%D0%BA%D0%B0 %D0%BD%D0%B0 %D0%BC%D0%BE%D0%BB%D0%BD%D0%B8%D0%B8

urlencoded -> UTF-8

Мужская черная толстовка на молнии

Long File Names

Amazing tool !! It saved me many hours.

I ran into some problems while using it though. Sometimes I wrote filenames in notion which were just too large.
To avoid this problem, I did a quick a dirty fix altering N2O.py (inserted after line 122):

        # Trim long titles
        if len(new_file_name ) > 200:
            new_file_name = new_file_name[:200]

This solved the issue of file names being too large, but I lost some information. If I had more time, I would look for a solution saving the previous title inside the markdown document for safekeeping.

File name of the images - Untitled.png

I've tried the script and although it does a great job, it generates many folders (each one of a note I guess) with files named untitled.png
This is a problem if I try to have a single image folder in obsidian.
Is it possible for it to acquire notename.1 notename.2 ...?

FileNotFoundError with long Cyrilic (potentially ASCII, too) filenames

It appears that N2O throws FileNotFound when any of the files has a very long name (no specific limit found for now).

It leads to the situation where it's practically impossible to migrate large workspaces

Will update the issue as I'll be manually moving Notion export to N2O-acceptabke way

The error looks as follows

Traceback (most recent call last):
  File "C:\Users\vlasi\Desktop\N2O test\Notion-2-Obsidan-master\N2O.py", line 132, in <module>
    with open(newfilepath, append_write, encoding='utf-8') as tempFile:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\vlasi\\AppData\\Local\\Temp\\tmpyfr6_amn\\ZettelKasten\\Сюжетная идея для игры долго борются с большим и сложным противником, а потом вдруг противник повержен, и нет четкого врага. В этот момент, предложить много ситуаций, где много насилия и использования всей накопленной силы по инерции обернется плохими последствиями.md'
PS C:\Users\vlasi\Desktop\N2O test\Notion-2-Obsidan-master>

Error

ModuleNotFoundError: No module named 'easygui'

I get this error

Quotes in URLs

Looks like there is a problem with the import, is titles have quotes in them. I thought I saw a solution here: Navirl@c9811d8 but it looks like that is out of date compared to master.

cannot import fileopenbox

Hey,

I've only just installed python and easygui to run this script, but the script fails here:

= RESTART: I:\Notion to Obsidian Export\N2O.py
Traceback (most recent call last):
File "I:\Notion to Obsidian Export\N2O.py", line 15, in
from easygui import fileopenbox
ImportError: cannot import name 'fileopenbox' from 'easygui' (I:\Notion to Obsidian Export\easygui_init_.py)

Not sure how to troubleshoot. Would appreciate any breakdown!

Databases

I've run the script a few times now, and it seems that the process gets stuck when a database page comes us. The error says "[Errno 63] File name too long." Is this a normal issue? Maybe the approach should be to have the script skip over each record with this error and print out a log at the end

_csv.Error: field larger than field limit

Hi I tried running the script on my Notion export and got this error. Not sure what to make of it -- my Notion export is huge ~5gb so I'd imagine its a stress test.

(base) PS D:\Notion-2-Obsidan-master> python .\N2O.py
Traceback (most recent call last):
  File ".\N2O.py", line 90, in <module>
    mdTitle = N2Omodule.N2Ocsv(csvFile)
  File "D:\Notion-2-Obsidan-master\N2Omodule.py", line 98, in N2Ocsv
    for row in reader: # I don't know how this works but it does what I want
  File "C:\Users\USER\Anaconda3\lib\csv.py", line 111, in __next__
    self.fieldnames
  File "C:\Users\USER\Anaconda3\lib\csv.py", line 98, in fieldnames
    self._fieldnames = next(self.reader)
_csv.Error: field larger than field limit (131072)

YAML frontmatter for tags.

It would be nice if the tags and metadata (potentialy UIDs as well ) would be formulated as Yaml frontmatter. Obsidian recognizes this and it would be super useful for downstream parsing.

# Convert tags after lines starting with "Tags:"

[Error]'PosixPath' object has no attribute 'seek'

Env:

  • MacOS 10.14.6
  • Python 3.6.1

After select zip file, the following error occurred:

objc[36412]: Class FIFinderSyncExtensionHost is implemented in both /System/Library/PrivateFrameworks/FinderKit.framework/Versions/A/FinderKit (0x7fff8dbd73f0) and /System/Library/PrivateFrameworks/FileProvider.framework/OverrideBundles/FinderSyncCollaborationFileProviderOverride.bundle/Contents/MacOS/FinderSyncCollaborationFileProviderOverride (0x117db4f50). One of the two will be used. Which one is undefined.
Traceback (most recent call last):
  File "N2O.py", line 22, in <module>
    notionsData = ZipFile(NotionZip, 'r')
  File "/Users/rosu/.pyenv/versions/3.6.1/lib/python3.6/zipfile.py", line 1100, in __init__
    self._RealGetContents()
  File "/Users/rosu/.pyenv/versions/3.6.1/lib/python3.6/zipfile.py", line 1164, in _RealGetContents
    endrec = _EndRecData(fp)
  File "/Users/rosu/.pyenv/versions/3.6.1/lib/python3.6/zipfile.py", line 241, in _EndRecData
    fpin.seek(0, 2)
AttributeError: 'PosixPath' object has no attribute 'seek'

Broken links to attachments

Hello!
Links to attachments created by the script are not working...
The links appear in Obsidian, but when I click on them, the app creates an empty folder.
Maybe the script doesn´t work anymore in Obsidian 1.0 (recently launched)?

Convert UTF8 to unicode issue with some 3bytes special key

commit 7525261a28ba46b91188a4ec048448969cb1296e

https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8192&number=128&utf8=string-literal
%E2%80%93%
%E5%A4%A9

ERROR: convert unicode failed
   b'\xe2\x80' in - ![Chuye%CC%A3%CC%82n%20ho%CC%A3c%20tie%CC%82%CC%81ng%20Anh%20%E2%80%93%20Pha%CC%82%CC%80n%201%20To%CC%82i%20%C4%91a%CC%83%20ho%CC%A3c%20364a6002c0a8412eae74d21ac3589e07/maxresdefault.jpg](Chuye%CC%A3%CC%82n%20ho%CC%A3c%20tie%CC%82%CC%81ng%20Anh%20%E2%80%93%20Pha%CC%82%CC%80n%201%20To%CC%82i%20%C4%91a%CC%83%20ho%CC%A3c%20364a6002c0a8412eae74d21ac3589e07/maxresdefault.jpg)

   b'\xe5\xa4' in -     ![Welcome%20to%20the%20Catholic%20Churches%20in%20Wuhan_%E5%A4%A9%E4%B8%BB%E6%95%99%E6%AD%A6%E6%98%8C%E5%A0%82%E5%8C%BA%E4%BF%9D%20451db740db1440989c2fb0e7cf4af9ef/E___0314EN00SIGT.gif](Welcome%20to%20the%20Catholic%20Churches%20in%20Wuhan_%E5%A4%A9%E4%B8%BB%E6%95%99%E6%AD%A6%E6%98%8C%E5%A0%82%E5%8C%BA%E4%BF%9D%20451db740db1440989c2fb0e7cf4af9ef/E___0314EN00SIGT.gif)

Lose link incase long file name of notion

Left side hand: export from notion
Right side hand: convert Notion to obsidian
image
notion exported file md keep information of file name in content. Should support this feature

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.