Import from Text Files
Posted: Sat Oct 29, 2011 4:28 am
I currently have a simple system - a 'Notes' directory on my hard drive containing a bunch of txt files. It works, but I liked the idea of a single UI. I've thought about writing my own, but CintaNotes looks pretty nice.
Though I've looked into CintaNotes a few times, I never took the plunge because it was incompatible with my current system (without resorting to excessive copy and paste). I've checked the roadmap, and it seems that it's on the list, but that doesn't help me now. I wanted to implement it myself, but despite being free, CintaNotes doesn't seem to be open source.
So I did what any good software developer would do, and I wrote myself a tool to do it for me. And, unlike CintaNotes, I'm releasing it as open source under the GPL
Right now, this just takes a directory of txt files and builds an XML file from them, using the files' created timestamps for the date. An export tool is planned, and I should have it for you guys soon. It was written in python, which for the record, I learned specifically to build this tool. For obvious reasons this will not work with a single text file created by CintaNotes, but it solved my problem and hopefully some others will find it helpful.
If you want to use it, install python and run this in the command line in the directory where you've got all your text files.
Though I've looked into CintaNotes a few times, I never took the plunge because it was incompatible with my current system (without resorting to excessive copy and paste). I've checked the roadmap, and it seems that it's on the list, but that doesn't help me now. I wanted to implement it myself, but despite being free, CintaNotes doesn't seem to be open source.
So I did what any good software developer would do, and I wrote myself a tool to do it for me. And, unlike CintaNotes, I'm releasing it as open source under the GPL
Right now, this just takes a directory of txt files and builds an XML file from them, using the files' created timestamps for the date. An export tool is planned, and I should have it for you guys soon. It was written in python, which for the record, I learned specifically to build this tool. For obvious reasons this will not work with a single text file created by CintaNotes, but it solved my problem and hopefully some others will find it helpful.
If you want to use it, install python and run this in the command line in the directory where you've got all your text files.
Code: Select all
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os, time
xmlFile = open('notes.xml', 'w')
xmlFile.write("<?xml version=\"1.0\"?>\n<notebook>\n")
fileList = os.listdir('.')
fileList.sort()
for fileName in fileList:
if(fileName.endswith(".txt")):
fileText = open(fileName).read()
fileStats = os.stat(fileName)
fileDate = time.localtime(fileStats[8])
fileDay = time.strftime("%Y-%m-%d", fileDate)
fileTime = time.strftime("%H:%M:%S", fileDate)
note = "<note title=\"%s\" date=\"%s\" time=\"%s\" source=\"\" link=\"\" tags=\"\">\n <![CDATA[%s]]>\n</note>\n" % (fileName, fileDay, fileTime, fileText)
xmlFile.write(note)
xmlFile.write("</notebook>\n");