![]() |
#1 |
Member
![]() Posts: 15
Karma: 10
Join Date: Dec 2009
Location: Belo Horizonte, Brazil
Device: Kindle 3 WiFi
|
Convert Text Dictionary to Mobi
I have a dictionary in text format that I would like to convert to mobi format. I am trying to convert it to the "keyword-tab-definition" format which I can translate into mobi using tab2opf. Unfortunately I don't know any tool able to make the conversion nor I have enough programming skills.
The dictionary looks like: word1 definition 1 definition 2 definition 3 word2 definition word3 definition 1 definition 2 Any hints (Linux or Windows)?. Thanks. |
![]() |
![]() |
![]() |
#2 |
Addict
![]() ![]() ![]() ![]() ![]() Posts: 219
Karma: 404
Join Date: Nov 2010
Device: Kindle 3G, Samsung SIII
|
For a very basic conversion, you can use something like this:
Code:
#!/usr/bin/python # coding: utf-8 inp='yourfile.txt' out='outfile.txt' new_entry=1 with open(inp) as f: with open(out,'w') as g: for line in f: line=line.strip() if new_entry: line+='\t' new_entry=0 elif not line: new_entry=1 line='\n' else: line='<BLOCKQUOTE>'+line+'</BLOCKQUOTE>' g.write(line) |
![]() |
![]() |
![]() |
#3 |
Member
![]() Posts: 15
Karma: 10
Join Date: Dec 2009
Location: Belo Horizonte, Brazil
Device: Kindle 3 WiFi
|
Thanks, janvanmaar.
I converted file using your script. Tried to convert output file to opf using tab2opf and got error message: File "Download/tab2opf.py", line 243, in <module> dd = normalizeUnicode(dd,'cp1252') File "Download/tab2opf.py", line 103, in normalizeUnicode text = unicode(text, 'utf-8') UnicodeDecodeError: 'utf8' codec can't decode byte 0xe1 in position 317: invalid continuation byte |
![]() |
![]() |
![]() |
#4 |
Addict
![]() ![]() ![]() ![]() ![]() Posts: 219
Karma: 404
Join Date: Nov 2010
Device: Kindle 3G, Samsung SIII
|
Your original file was probably not utf. Convert it to utf first and then repeat the conversion to tab-delimited file and mobigen building.
|
![]() |
![]() |
![]() |
Tags |
dictionary, mobi, text |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Mobi dictionary lookup | 1mikemoroz | Kindle Formats | 8 | 03-21-2011 05:29 AM |
Convert eReader Dictionary to MOBI? | notyou | Other formats | 2 | 06-29-2010 01:37 AM |
Convert zip with multiple text files to MOBI | mindfire | Calibre | 1 | 03-27-2010 10:19 AM |
Mobi Dictionary | alterego | Kindle Formats | 0 | 10-30-2009 01:30 AM |
will Mobi dictionary work in oi | legin | OpenInkpot | 2 | 07-30-2009 02:07 PM |