How to edit non-Bible modules (.twm)

Share your favorite tips, workarounds and shortcuts for theWord
csterg
Site Admin
Posts: 8621
Joined: Tue Aug 29, 2006 3:09 pm
Location: Corfu, Greece
Contact:

How to edit non-Bible modules (.twm)

Post by csterg »

This info applies to version 3.
All non-Bible modules have an extension .twm (TheWordModule). These files are sqlite3 database files.
To read more about the sqlite database see here: http://www.sqlite.org

To edit these files you may use any of the free editors that can work with sqlite files. Please, see list here: http://www.sqlite.org/cvstrac/wiki?p=ManagementTools

I personally use the following 3 programs to edit the .twm files:
1. http://www.sqliteexpert.com/ (Personal edition which is free)
2. http://www.singular.gr/sqlite/
3. http://www.yunqa.de/delphi/doku.php/products/sqlitespy/

Although i prefer the first one, the second provides unicode support. It seems that may be better tools that these, it's just a personal opinion.

Since the word 'database' seems to intimidate some people, let me write shortly what it is:
A database file is just a structured file that contains data organized in tables (columns and rows). In order to change the content of a database file, instead of using an editor, you can use a language that is called SQL. The tools above make it easy to give such commands in order to read or alter these files. You don't need to worry how the data are organized in the file itself, the tools above can show you these data in tabular format (something like excel).

The twm files contain a number of tables each where the actual data are stored. The structures are quite simple to understand. As an example, i will tell how you can add to a dictionary the flag that it is a strong dictionary.

All twm file contain a table called 'config'. This table contains 2 columns, one called 'name', the other called 'value'. As you can see, this is used to store parameters (name=value).
In order for a dictionary to be flagged as containing strong definitions, one row should be added with name=strong and value=1. To do that, you open the file with one of the tools and you just execute the following SQL command:

Code: Select all

insert into config(name,value) values('strong',1);
In order to check all the values of this table, just write

Code: Select all

select * from config;
For sqlite explorer: in order to execute one of these statements, you just type it and press Execute (F9). The result are shown below.

I hope this is clear, if not i can add more details,
Costas
User avatar
nikolay_l
Posts: 511
Joined: Thu Dec 09, 2010 3:29 pm
Location: Россия, Крым, Севастополь
Contact:

Re: How to edit non-Bible modules (.twm)

Post by nikolay_l »

how to work of field ''blob'' in ''content.data'' ?
Last edited by nikolay_l on Sun Mar 11, 2012 9:12 pm, edited 1 time in total.
«Мыши плакали, кололись, но продолжали жрать кактус»
UBC4ME
Posts: 153
Joined: Mon Nov 02, 2009 2:43 am
Location: Greenville, South Carolina

Re: How to edit non-Bible modules (.twm)

Post by UBC4ME »

Costas,

Thank you so much for this information. The more information you can supply, in as basic terms as possible, the better those of us who are not familiar with SQL can work. For myself this is great! Thank you
Dave
Gods gifts comes wrapped many different ways.
Manuel
Posts: 174
Joined: Wed May 05, 2010 12:45 am
Location: Santiago, Chile

Re: How to edit non-Bible modules (.twm)

Post by Manuel »

nikolay_l wrote:how to work of field ''blob'' in ''content.data'' ?
Nikolai.
Quoting Costas.

In SQLite:
Code:
select ''||data from content;

This will format the blob as string and you will see it's content. Remember to convert the module to RTF first to be able to edit.

I think there is an ODBC driver for SQLite. Google it,

Hope this helps,
Manuel.
Awaiting the return of the Lord (The Glorious rapture of the Church)...

http://jesus-christ-is-coming.blogspot.com/
http://www.cristo-viene.cl
User avatar
nikolay_l
Posts: 511
Joined: Thu Dec 09, 2010 3:29 pm
Location: Россия, Крым, Севастополь
Contact:

Re: How to edit non-Bible modules (.twm)

Post by nikolay_l »

thanks, - we will try it's understood
matara
Posts: 4
Joined: Mon Mar 12, 2012 10:06 pm

Re: How to edit non-Bible modules (.twm)

Post by matara »

Hi guys.
I want read "data" column in "content" table.
I want to create a new database with modified data.

When I read data from this column I get string with not understand for me type.

How I know 'blob' type it's binary data storage, it's used for save text and pictures. I want know how can I read data, get text , get pictures or else.

For programming I use ruby on rails.
csterg
Site Admin
Posts: 8621
Joined: Tue Aug 29, 2006 3:09 pm
Location: Corfu, Greece
Contact:

Re: How to edit non-Bible modules (.twm)

Post by csterg »

The actual content type in there is either 'rtf' or 'rvf'.
You need to read the spec of these format. Stick with rtf, read the spec here: http://www.biblioscape.com/rtf15_spec.htm
You can convert a module to rtf format from the 'Module Properties' dialog (see second tab, Actions)
Costas
matara
Posts: 4
Joined: Mon Mar 12, 2012 10:06 pm

Re: How to edit non-Bible modules (.twm)

Post by matara »

thanx, that's I need.
matara
Posts: 4
Joined: Mon Mar 12, 2012 10:06 pm

Re: How to edit non-Bible modules (.twm)

Post by matara »

At long time I can't read data because compression was included.

How work this compression?
In what columns it mark that is compressed?

What formula to compress and uncompress data.
matara
Posts: 4
Joined: Mon Mar 12, 2012 10:06 pm

Re: How to edit non-Bible modules (.twm)

Post by matara »

It's a simple gzip coded text?
And in DB marked as config.comressed 0 or 1?

Exist something else?
csterg
Site Admin
Posts: 8621
Joined: Tue Aug 29, 2006 3:09 pm
Location: Corfu, Greece
Contact:

Re: How to edit non-Bible modules (.twm)

Post by csterg »

matara wrote:It's a simple gzip coded text?
And in DB marked as config.comressed 0 or 1?

Exist something else?
Yes, it is simple gzip compression and the last 30 bytes contain a signature (fixed) that denote that the field is compressed. The config.compressed is mostly pointing to whether the whole module is compressed.
If you need the signature in bytes tell me,
Costas
kadmy
Posts: 2
Joined: Wed Oct 10, 2012 8:54 pm

Re: How to edit non-Bible modules (.twm)

Post by kadmy »

hi all!

Costas, thank you for information, but I'd like to know how can I extract the data, pls?
csterg
Site Admin
Posts: 8621
Joined: Tue Aug 29, 2006 3:09 pm
Location: Corfu, Greece
Contact:

Re: How to edit non-Bible modules (.twm)

Post by csterg »

kadmy wrote:hi all!

Costas, thank you for information, but I'd like to know how can I extract the data, pls?
Be more specific pls of what you are trying to accomplish and how,
Costas
kadmy
Posts: 2
Joined: Wed Oct 10, 2012 8:54 pm

Re: How to edit non-Bible modules (.twm)

Post by kadmy »

I tried understand how programmatically to get 'data' field (how to uncompress it), how after this to use 'rvf' format (which rvt->rtf converters exist, for example for .Net or oOoffice basic).

But now the question is resolved, I done convertation of module to rtf format as you described above. Thank you very much.
csterg
Site Admin
Posts: 8621
Joined: Tue Aug 29, 2006 3:09 pm
Location: Corfu, Greece
Contact:

Re: How to edit non-Bible modules (.twm)

Post by csterg »

Welcome. Just to answer quickly, the easiest way to uncompress and convert to rtf is from within theWord itself, else it's kind of difficult to program it
Costas
Post Reply