Import Question

Dear all,

I have a plain ASCII file containing a number of lines of text. How do I import this file in such a way that each line ends up as a separate note or todo (importing the file as an .md-file results in the entire file ending up as a single note).

Regards,
kai.

Joplin 2.7.14 (prod, linux)

Client-ID: 3708fbfebb3646c787c57619e7200257
Sync-Version: 3
Profil-Version: 41
Unterstützter Schlüsselbund: Nein

Revision: 98fba37

Hi,

you could do that by leveraging joplins data API. A python script could look like:

from joppy.api import Api

api = Api(token="YOUR_TOKEN")

notebook_id = api.add_notebook(title="Imported Notes")

with open("/path/to/text/file.txt") as infile:
    for line_index, line_content in enumerate(infile.readlines()):
        api.add_note(
            title=f"Line {line_index}",
            body=line_content,
            parent_id=notebook_id
        )

If you want to try it, make sure to use a small sample file first.

2 Likes

hi,
thanks for the feedback. I was actually hoping for something easier/quicker; perhaps something I had overlooked in the IMPORT functionality, so I don't know whether I would like to run something like this everytime I need to import; but it's an interesting solution; thanks.

Regards,
kai.

If you need to split the file first then linux has all kinds of tools for it.
Something like a basic file per literal line:
split -l 1-d --additional-suffix=.md big_file.md new_file

Then import those.

1 Like

Yes, I thought about using Linux tooling and it'll probably work, but for me that would only be an interim solution; I would prefer some function in Joplin for this; and I'm probably the only person asking for such a feature so I'm not getting my hopes up :slightly_smiling_face:

Thanks for your suggestion,
kai.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.