Retrieve database structure from txt backup

marzban

Retrieve database structure from txt backup

Postby marzban » Mon Sep 05, 2011 1:02 pm

Hi,

Due to some confusion, only have the txt file backup and not the db file. Is there anyway I can import the txt file back to new install of Cinta with the old structure restored? Thanks.
ale
Moderator
Posts: 202
Joined: Fri Feb 06, 2009 6:01 pm

Re: Retrieve database structure from txt backup

Postby ale » Tue Sep 06, 2011 2:56 pm

Hello marzban, unfortunately the .txt format is not a (complete) backup, in fact it's called export and not backup in CN. It lacks some informations as for example the tags assigned to notes. So it's not possible to restore 100% of informations from the .txt format. A good backup is the .db file or in second instance the .xml export (which retains all informations).

AFAIK CintaNotes can't import from .txt files although something is planned. If you somewhat want your notes back into CN without being 100% accurate, you can try to transform the .txt file into a structured .xml file and then import it.

If you can do it or have yor own tools well it's good :) if this is not possible I have a half-baked half-working ugly solution so I'm a bit hesitant to write it... well as a last resort, a simple text editor can help...

I exported my notes to .txt format then I used the free EditPad Light and its search and replace function put in Regex mode and used this as a search pattern:

Code: Select all

\[(\d{1,2})\/(\d{1,2})\/(\d{1,4}) (\d{1,2})\.(\d{1,2})\.(\d{1,2})\] (.*)\r\n(?s)((.*?)(?=(\[\d{1,2}\/\d{1,2}\/\d{1,4} \d{1,2}\.\d{1,2}\.\d{1,2}\])))

and this replace one:

Code: Select all

<note title="$7" date="$3-$2-$1" time="$4:$5:$6" source="" link="" tags="">
  <![CDATA[$8]]>
</note>\r\n

then our file need two or three more obvious fixes...
put at the beginning of the file

Code: Select all

<?xml version="1.0"?>
<notebook>
and the closing tag at the bottom

Code: Select all

</notebook>
then save as .xml with an Unicode encoding (UTF-16 LE with BOM signature in EditPad Light, Windows Notepad simply call this "Unicode").

The problem with this approach is that I don't know regular expression very well :D but better than nothing so for my notebook a few notes seems lost or garbled (half a dozen of about two thousands, well for example the very last note always need manual fixing. I think it's all I can say about this problem (lack of intelligence :D and time, I'm very busy these days :( ), good luck :)
If other users can help I'm happy and feel free to use and correct my code.

Return to “CintaNotes Personal Notes Manager”