Can CN import my TXT note files (generated by ResophNotes) ?
-
- Posts: 4
- Joined: Sun Apr 15, 2012 2:57 am
- Contact:
Can CN import my TXT note files (generated by ResophNotes) ?
Hi,
Q:
How can I import all my existing .TXT note files into CN?
(all these .TXT files were previously generated by ResophNotes)
All my current Resoph-generated .txt files,
(about 500 .TXT files),
are stored in a Folder, on my PC.
I need to "migrate" them into CN...
tks!
SFdude
XP Pro SP3 - 32bit
FF 11
CN Free -latest version.
Q:
How can I import all my existing .TXT note files into CN?
(all these .TXT files were previously generated by ResophNotes)
All my current Resoph-generated .txt files,
(about 500 .TXT files),
are stored in a Folder, on my PC.
I need to "migrate" them into CN...
tks!
SFdude
XP Pro SP3 - 32bit
FF 11
CN Free -latest version.
- CintaNotes Developer
- Site Admin
- Posts: 5003
- Joined: Fri Dec 12, 2008 4:45 pm
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
Hi!
OK this seems to be a VERY frequent demand, so I've cooked a simple program
to do just that: iterate over a folder, read all .TXT files and create a single XML file
which is importable into CN.
Example:
You have a directory with .txt files, say it is D:\SNIPPETS.
You download the file below and unpack it into D:\, then run
If your text snippet directory contains subdirs with more .txt files, add the -r switch ("recurse").
If your text file encoding is not UTF-8 but UTF-16, then add the "-e utf-16" switch:
After that you run CintaNotes and import the resulting XML file.
Actually the program is self-explanatory, just run txtdir2xml.exe without any arguments.
Please let me know how did the import go.
Cheers
OK this seems to be a VERY frequent demand, so I've cooked a simple program
to do just that: iterate over a folder, read all .TXT files and create a single XML file
which is importable into CN.
Example:
You have a directory with .txt files, say it is D:\SNIPPETS.
You download the file below and unpack it into D:\, then run
txtdir2xml D:\SNIPPETS snippets.xml
If your text snippet directory contains subdirs with more .txt files, add the -r switch ("recurse").
If your text file encoding is not UTF-8 but UTF-16, then add the "-e utf-16" switch:
txtdir2xml -e utf-16 -r D:\SNIPPETS snippets.xml
After that you run CintaNotes and import the resulting XML file.
Actually the program is self-explanatory, just run txtdir2xml.exe without any arguments.
Please let me know how did the import go.
Cheers
- Attachments
-
- txtdir2xml.zip
- (2.53 MiB) Downloaded 1551 times
Alex
-
- Posts: 4
- Joined: Sun Apr 15, 2012 2:57 am
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
Hi Alex,
Thanks for the quick response.
A brief follow-up question
before I test your new XML converter pgm.,
(if you don't mind, of course):
( a ) The unzipped file size
of the main program:
.... "CintaNotes.EXE" (version 1.6),
is ~ 1.5 MBs.
( b ) The unzipped file size
of the new XML converter program:
.... "txtdir2xml.EXE"
is ...over 4.5 MBs !.
(ie: 3 times larger than the main prog...).
Why is that?
Does the new XML converter program:
"txtdir2xml.EXE"
install any libraries or add any changes in my PC?
(ie: Java, .NET, Python, Win registry changes, etc.)?
Reason I'm asking:
- I want to make sure the new converter pgm.
is totally portable,
and will not change or add anything
to my Win XP, when I run it...
Thanks!
SFdude
Thanks for the quick response.
A brief follow-up question
before I test your new XML converter pgm.,
(if you don't mind, of course):
( a ) The unzipped file size
of the main program:
.... "CintaNotes.EXE" (version 1.6),
is ~ 1.5 MBs.
( b ) The unzipped file size
of the new XML converter program:
.... "txtdir2xml.EXE"
is ...over 4.5 MBs !.
(ie: 3 times larger than the main prog...).
Why is that?
Does the new XML converter program:
"txtdir2xml.EXE"
install any libraries or add any changes in my PC?
(ie: Java, .NET, Python, Win registry changes, etc.)?
Reason I'm asking:
- I want to make sure the new converter pgm.
is totally portable,
and will not change or add anything
to my Win XP, when I run it...
Thanks!
SFdude
- CintaNotes Developer
- Site Admin
- Posts: 5003
- Joined: Fri Dec 12, 2008 4:45 pm
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
Great question!
I think you're aware of app vs. programmer productivity dilemma?)
Absolutely no libraries get installed, the app is 100% portable.
I've created the app using Python 3.2.3 and cx_Freeze.
The file size is large because it contains, it packed form, the whole Python runtime.
If you're still suspicious, here is the source Python script, you are welcome to try/use/modify it
I think you're aware of app vs. programmer productivity dilemma?)
Absolutely no libraries get installed, the app is 100% portable.
I've created the app using Python 3.2.3 and cx_Freeze.
The file size is large because it contains, it packed form, the whole Python runtime.
If you're still suspicious, here is the source Python script, you are welcome to try/use/modify it
Code: Select all
import argparse as ap
import os, os.path
from xml.dom.minidom import Document as XmlDocument
import time
VERSION = "1.0"
GREETING = "CintaNotes TXT folder importer V%s.\n" % VERSION
def main():
print(GREETING)
argsParser = createArgsParser()
argsParser.print_help()
args = argsParser.parse_args()
print('Processing..')
count = convert(args.inputFolder, args.outputXML, args.encoding, args.recurse)
print('\n-> Converted %d file(s).' % count)
def createArgsParser():
parser = ap.ArgumentParser(description = "Converts folders with text files to importable XML. Only files with .txt extension are read.")
parser.add_argument("inputFolder",
help = 'Folder with TXT files to be converted.',
type = str)
parser.add_argument("outputXML",
help = 'Resulting XML file name',
type = str)
parser.add_argument("-e", "--encoding", dest="encoding", help = 'Encoding of TXT files: utf-8 (default) or utf-16', type = str, default = 'utf-8')
parser.add_argument("-r", "--recurse", dest="recurse", help = 'Recurse into subdirectories', action = 'store_true', default = False)
return parser
def convert(inputFolder, outputXML, encoding, recurse):
xml = XmlDocument()
root = xml.createElement('notebook')
root.setAttribute('version', '1600')
xml.appendChild(root)
count = convertFiles(inputFolder, xml, encoding, recurse)
output = open(outputXML, 'w', encoding = 'utf-16le')
output.write(xml.toprettyxml())
return count
def convertFiles(inputFolder, xmlDocument, encoding, recurse):
count = 0
for root, dirs, files in os.walk(inputFolder):
for file in files:
(name, ext) = os.path.splitext(file)
if ext == '.txt':
addTextFileToXml(os.path.join(root, file), xmlDocument, encoding)
count = count + 1
if not recurse:
break
return count
def addTextFileToXml(filePath, xmlDocument, encoding):
filePath = os.path.abspath(filePath)
file = open(filePath, encoding = encoding)
(_, filename) = os.path.split(filePath)
(title, _) = os.path.splitext(filename)
body = removeBOM(file.read())
note = xmlDocument.createElement('note')
note.setAttribute('title', title)
note.setAttribute('link', 'file://' + filePath)
note.setAttribute('tags', '')
note.setAttribute('source', filePath)
note.setAttribute('created', getCreatedTime(filePath))
note.setAttribute('modified', getModifiedTime(filePath))
noteBody = xmlDocument.createCDATASection(body)
note.appendChild(noteBody)
xmlDocument.documentElement.appendChild(note)
def getCreatedTime(filePath):
return timeToStr(os.path.getctime(filePath))
def getModifiedTime(filePath):
return timeToStr(os.path.getmtime(filePath))
def timeToStr(tm):
return time.strftime('%Y%m%dT%H%M%S', time.gmtime(tm))
def removeBOM(s):
if s.startswith('\uFEFF') or s.startswith('\uFFFE') or s.startswith('\uEFBBBF'):
return s[1:]
return s
if __name__ == '__main__': main()
Alex
-
- Posts: 1324
- Joined: Tue Mar 08, 2011 11:15 am
Re: Can CN import my TXT note files (generated by ResophNote
Hi SFdude,
Thomas
Cintanotes.exe is packed. I guess the converter program is not, thus it appears to be larger.SFdude wrote:Hi Alex,( a ) The unzipped file size
of the main program: ... "CintaNotes.EXE" (version 1.6), is ~ 1.5 MBs. ( b ) The unzipped file size of the new XML converter program: .... "txtdir2xml.EXE" is ...over 4.5 MBs !. (ie: 3 times larger than the main prog...). Why is that?
I don't expect the app to do so, since CN itself is highly portable. However, only Alex can tell.SFdude wrote:Does the new XML converter program:
"txtdir2xml.EXE"
install any libraries or add any changes in my PC?
(ie: Java, .NET, Python, Win registry changes, etc.)?
Thomas
-
- Posts: 1324
- Joined: Tue Mar 08, 2011 11:15 am
Re: Can CN import my TXT note files (generated by ResophNote
CintaNotes Developer wrote:I've created the app using Python 3.2.3 and cx_Freeze.
Nice program Alex Maybe you should allow a tag-list (plain string) to be passed by the command line?!
Thomas
- CintaNotes Developer
- Site Admin
- Posts: 5003
- Joined: Fri Dec 12, 2008 4:45 pm
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
Do you mean that all notes will be tagged with same tags?
Alex
-
- Posts: 1324
- Joined: Tue Mar 08, 2011 11:15 am
Re: Can CN import my TXT note files (generated by ResophNote
CintaNotes Developer wrote:Do you mean that all notes will be tagged with same tags?
Yes. I can use a file filter to convert a group or a single file and tag it while converting, e.g. convert cintanotes*.txt -tags:"cintanotes outliner", convert word*.txt -tags:"word faq". That requests converting files in separate steps, but adds more flexibility. It's optional and should be fairly easy to implement
- CintaNotes Developer
- Site Admin
- Posts: 5003
- Joined: Fri Dec 12, 2008 4:45 pm
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
I see. Well, for 1.7 I'm planning an "Add Tags" field for the Import dialog, so this will become a non-issue anyway - I guess it can wait till then.
Also there is a simple workaround: just create a new notebook, import the XML into it, select all notes and tag them, and after that switch to target notebook and import the new notebook into it (or just copy-paste the notes).
Also there is a simple workaround: just create a new notebook, import the XML into it, select all notes and tag them, and after that switch to target notebook and import the new notebook into it (or just copy-paste the notes).
Alex
-
- Posts: 1324
- Joined: Tue Mar 08, 2011 11:15 am
Re: Can CN import my TXT note files (generated by ResophNote
CintaNotes Developer wrote:I see. Well, for 1.7 I'm planning an "Add Tags" field for the Import dialog, so this will become a non-issue anyway - I guess it can wait till then.
Also there is a simple workaround: just create a new notebook, import the XML into it, select all notes and tag them, and after that switch to target notebook and import the new notebook into it (or just copy-paste the notes).
Fine. That should handle the issue
Thomas
-
- Posts: 4
- Joined: Sun Apr 15, 2012 2:57 am
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
Ahh! Understood.
Thanks Alex & Thomas Lohrum,
for explaining the big file size difference.
Just to confirm:
So, running "txtdir2xml.EXE",
will not change, add or install Python (or other libs)
on my PC, right?
(...it's as if I'm running a "portable", self-contained pgm...).
Thanks for you patience guys!
SFdude
Thanks Alex & Thomas Lohrum,
for explaining the big file size difference.
Just to confirm:
So, running "txtdir2xml.EXE",
will not change, add or install Python (or other libs)
on my PC, right?
(...it's as if I'm running a "portable", self-contained pgm...).
Thanks for you patience guys!
SFdude
-
- Posts: 1324
- Joined: Tue Mar 08, 2011 11:15 am
Re: Can CN import my TXT note files (generated by ResophNote
SFdude wrote:So, running "txtdir2xml.EXE", will not change, add or install Python (or other libs) on my PC, right?
Yes. See Alex's answer:
CintaNotes Developer wrote:Absolutely no libraries get installed, the app is 100% portable.
-
- Posts: 4
- Joined: Sun Apr 15, 2012 2:57 am
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
ok -
thanks for the reassurance, Thomas.
Really look forward
to trying out CintaNotes.
SFdude
thanks for the reassurance, Thomas.
Really look forward
to trying out CintaNotes.
SFdude
- CintaNotes Developer
- Site Admin
- Posts: 5003
- Joined: Fri Dec 12, 2008 4:45 pm
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
SFDude,
Thomas is right, the program won't insall anything on your system.
Please share with us how did the import go.
Thomas is right, the program won't insall anything on your system.
Please share with us how did the import go.
Alex
-
- Posts: 4
- Joined: Thu Apr 19, 2012 6:14 am
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
Now this is lovely. I've got a bunch of text files from my phone (notes here and there), my primary notetaker on the go, and this would make it easier to import to Cinta.
Re: Can CN import my TXT note files (generated by ResophNote
txtdir2xml does not work on my XP SP3 system. I get this error message:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa3 in position 657: invalid start byte
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa3 in position 657: invalid start byte
- CintaNotes Developer
- Site Admin
- Posts: 5003
- Joined: Fri Dec 12, 2008 4:45 pm
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
Hi Mark B.,
please check that all your TXT files have UTF-8 encoding.
If they are UTF-16 (2 bytes per character), please add the "-e utf-16" parameter.
please check that all your TXT files have UTF-8 encoding.
If they are UTF-16 (2 bytes per character), please add the "-e utf-16" parameter.
Alex
Re: Can CN import my TXT note files (generated by ResophNote
Hello Alex,
They're all utf-8 according the Notepad++. But I still get the same problem, with one slight difference: position 660 instead of 657.
(the -e parameter doesn't help, as expected).
Also Avira AV doesn't like the program, it claims to detect the presence of the "TR/Crypt.ULPM.Gen2" virus in it.
They're all utf-8 according the Notepad++. But I still get the same problem, with one slight difference: position 660 instead of 657.
(the -e parameter doesn't help, as expected).
Also Avira AV doesn't like the program, it claims to detect the presence of the "TR/Crypt.ULPM.Gen2" virus in it.
-
- Posts: 1324
- Joined: Tue Mar 08, 2011 11:15 am
Re: Can CN import my TXT note files (generated by ResophNote
Hi Guest,
I can not confirm your alert. I use Avira Pro with the latest signatures and CintaNotes 1.6.2.
Which version of CN are you running?
Thomas
[EDIT]As of May 15 Aviras ProActiv Module was giving false alerts. A fix was released last night.
CintaNotes Developer wrote:Also Avira AV doesn't like the program, it claims to detect the presence of the "TR/Crypt.ULPM.Gen2" virus in it.
I can not confirm your alert. I use Avira Pro with the latest signatures and CintaNotes 1.6.2.
Which version of CN are you running?
Thomas
[EDIT]As of May 15 Aviras ProActiv Module was giving false alerts. A fix was released last night.
Last edited by Thomas Lohrum on Wed May 16, 2012 7:53 am, edited 1 time in total.
- CintaNotes Developer
- Site Admin
- Posts: 5003
- Joined: Fri Dec 12, 2008 4:45 pm
- Contact:
Re: Can CN import my TXT note files (generated by ResophNote
Guest wrote:They're all utf-8 according the Notepad++. But I still get the same problem, with one slight difference: position 660 instead of 657.
(the -e parameter doesn't help, as expected).
Are you sure that the file is not corrupt? Have you tried excluding this file from import? If you could send this file to me to support@cintanotes.com, it would greatly help in fixing this problem. Thanks!
Alex
Return to “CintaNotes Personal Notes Manager”