Results 1 to 19 of 19

Thread: Using OpenOffice to edit DB entries (via TSV export)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Using OpenOffice to edit DB entries (via TSV export)

    Using OpenOffice to edit DB entries (via TSV export)

    Introduction

    OpenOffice is a great open source (i.e. free) office software suite. It includes a text editor, a drawing software that's useful for creating diagrams, a presentation software and, most importantly for modding, a spreadsheet editor. Today, I want to show you how you can edit TSV (tab-separated value) files exported from PFM in OpenOffice, which is how I imagined they would be used when writing the export mechanism.

    A TSV file is a text table representing a database table. In this, the different columns of the table are separated by tabs and the rows correspond to the lines. In principle, you can use a text editor to edit TSV files but they quickly become unwieldy if the column width differs between rows, such as when editing text. Therefore, editing them in a spreadsheet program is much to be preferred.


    Requirements and Preparation

    I will assume that you know how to use PFM to open and edit pack files, and that you know how to set up a mod with a modding pack that you can use for examples.

    If you don't have it yet, download and install OpenOffice. To do this, go to this site and follow the green arrow. It will take a bit of setting up like entering your details, etc.

    Now, create a mod pack with an example mod file you want to edit - the best choice for this tutorial is a file you know well. OpenOffice is most useful for files that are very large (for example localisation.loc), where you need to do a lot of copy&paste (for example unit_stats when creating new units), or where you want to use formulas to calculate something.


    1. Exporting from PFM

    First, open your mod pack file in PFM and navigate to the DB file you want to edit. I'll use the units table. Then, click on the Export TSV button highlighted below. This will open a dialog asking you where to save the file. Save it somewhere with the default name (units.tsv in my case) and remember the location (the data directory for example).



    2. Opening a TSV file

    Fire up OO Calc via the start menu and you should arrive at a screen that looks like this:



    To open your TSV file, open an explorer window, navigate to your working directory, then drag&drop the file into your OpenOffice Calc window. Using the File->Open dialog is possible but in this case you have to rename your file from units.tsv to units.txt so I typically prefer the drag&drop. When you open a TSV file, OO will ask you how it should handle the file format:



    You have to make two adjustments in this dialog. Firstly, you have to select UTF-8 as encoding in the Character Set dropbox. The easiest way to do this is to hit the "u" key on your keyboard three times after the dialog opens. The second change is to remove the Text Delimiter (usually a quotation mark). Afterwards, the dialog should look like this:



    Click OK to continue and OpenOffice will open your file.


    3. Editing, saving and re-importing

    Don't edit the first two lines which are internal settings for PFM. Editing the third line with the column descriptions is fine but the changes won't show up in PFM. Do any changes you'd like to make, then hit save (ctrl+s). OpenOffice will by default ask you if you want to save in the current format or in ODS format (the native OpenOffice format). Click on "Keep Current Format"; if you like you can uncheck the checkbox so OO won't ask you about this again.



    Now, unfortunately, due to OpenOffice including a file locking mechanism, you have to close the OO table to re-import the file into PFM. So close it, switch to your open PFM window, select the file you're editing again if it's not selected anymore, and hit "Import TSV". Check your changes worked and you're done.

    Thank you for your attention.



    Useful Reading

    How to create a mod by Erasmus
    Last edited by alpaca; May 28, 2010 at 05:01 PM.

    No thing is everything. Every thing is nothing.

  2. #2

  3. #3
    Thoragoros's Avatar Citizen
    Join Date
    Jan 2006
    Location
    New York
    Posts
    4,822

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Quote Originally Posted by Iutland View Post
    Good with some basic tutorials including explainative screenshots +Rep

    iutland
    Alpaca is the harbinger of saliva and spits upon rep.

    Anyway, great advice Alpaca! I'll be applying this to the Great War to make editing the loc easier. Thanks!
    Founder of The Great War - A WWI Mod, Creator of Thorized - Napoleon: Total Combat

    Where Gods Walk Among Men
    The Line of Thor
    Patron of: Bethencourt, Hip63, m_1512

    Under the Patronage of Captain Blackadder, Member of the Legion of Rahl.

  4. #4
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Quote Originally Posted by Thoragoros View Post
    Alpaca is the harbinger of saliva and spits upon rep.
    Indeed.

    No thing is everything. Every thing is nothing.

  5. #5

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    I am working always with OO since modding suits better with open source programs. Based on my experience I do not think that all these instructions in step 2 are needed . You can just double click on TSV (maybe the first time you have to associate scalc as the default program, in my case there was need) and then OK in small window (what ever shows there). When you've done close the file from the x in upper right corner and answer yes in saving changes.

    The only TSV that I've found so far the above instructions necessary is localisation_loc of other languages than English, especially German one.
    Last edited by husserlTW; May 19, 2010 at 05:13 AM.




  6. #6
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Quote Originally Posted by husserlTW View Post
    I am working always with OO since modding suits better with open source programs. Based on my experience I do not think that all these instructions in step 2 are needed . You can just double click on TSV (maybe the first time you have to associate scalc as the default program, in my case there was need) and then OK in small window (what ever shows there). When you've done close the file from the x in upper right corner and answer yes in saving changes.

    The only TSV that I've found so far the above instructions necessary is localisation_loc of other languages than English, especially German one.
    Double-click file association should work, I didn't think of it. Thanks.

    As for the rest: Changing to Unicode is fairly important. If you don't do it, any é and many other special characters in your file will not be interpreted correctly. It works for many of the DB files but I found it safer to tell people to change it (it's not a lot of work, really). The text delimiter is necessary if you want to use quotation marks in your texts (typically in the loc file), otherwise PFM removes the quotes.

    No thing is everything. Every thing is nothing.

  7. #7

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Quote Originally Posted by alpaca View Post
    As for the rest: Changing to Unicode is fairly important. If you don't do it, any é and many other special characters in your file will not be interpreted correctly. It works for many of the DB files but I found it safer to tell people to change it (it's not a lot of work, really). The text delimiter is necessary if you want to use quotation marks in your texts (typically in the loc file), otherwise PFM removes the quotes.
    You are right about _loc TSV's I had forgotten those details. But I open so many times TSV files every day that I hate even clicking OK in the pop up window. Btw is there a way for this window to be always on top? Because if I have other windows opened on desktop, this pop up uses to open always underneath...




  8. #8
    alpaca's Avatar Harbinger of saliva
    Join Date
    Sep 2005
    Location
    Germany
    Posts
    4,811

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Quote Originally Posted by husserlTW View Post
    You are right about _loc TSV's I had forgotten those details. But I open so many times TSV files every day that I hate even clicking OK in the pop up window. Btw is there a way for this window to be always on top? Because if I have other windows opened on desktop, this pop up uses to open always underneath...
    IDK, probably not. If you use drag&drop it's automatically focused.

    No thing is everything. Every thing is nothing.

  9. #9

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Thank you for the very clear explanation. Very helpful!

  10. #10

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    I just downloaded the newest OpenOffice and it is nothing like this, I opened the file I extracted, set it to UTF-8 and got a bunch of #$%^&* characters, anyone know what to do? I opened the extracted file in googles office but it will not show changes when I import. I'm lost.

  11. #11

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    This is so insane. Ok I got it to open right, it kept trying to open in writer...anyway set UTF-8 and got rid of delimiter, display in tab and now there are no characters in the unit limit tab which is broken into 2 tabs? I opened this in gdocs, it opened fine, all characters were there, tab headers not broken into 2 tabs, edited it, saved,checked it, imported it into pack, but my changes didn't show.

    I've directly edited the pack and it showed, but what I'm trying to do requires a lot fo fields to be edited so I need a way to edit a tsv.

    Can anyone help?

  12. #12

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Again I answered my own questions, got it working! But thanks for any future input.
    Last edited by Wolves In The Throne Room; June 28, 2011 at 07:32 PM. Reason: edit

  13. #13

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Thanks for the tutorial. Using Calc makes modding many units at once easy.
    I don't always talk in tautologies, but when I do, I talk in tautologies.




  14. #14
    agunter999's Avatar Senator
    Join Date
    Apr 2012
    Location
    UK or not????
    Posts
    1,475

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    i can not reimport it
    it says string was not recognised as a valid boolean

  15. #15
    agunter999's Avatar Senator
    Join Date
    Apr 2012
    Location
    UK or not????
    Posts
    1,475

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    could sombody try to atempt to spot my mistake
    thanks

  16. #16

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Bollean column (Z) is completely empty. Spaces cannot replace a True/False value. Fill it with True in all cells and you are good to go.

    I also noticed that the units are the Empire vanilla hole set? Are you trying to transfer all Empire units in Napoleon? If not and you are working in Empire then this table is wrong (delete the last 3 columns). If you do transfer, perhaps you will find troubles with DLC units.
    Last edited by husserlTW; June 05, 2012 at 07:19 AM.




  17. #17
    Domesticus
    Join Date
    May 2010
    Location
    Ferrara, Italy
    Posts
    2,175

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Which version you have to OO?


    I have version 4.1.1.


    I can not import in PFM.
    Last edited by Crociato78; April 11, 2015 at 06:48 PM.

  18. #18
    Domesticus
    Join Date
    May 2010
    Location
    Ferrara, Italy
    Posts
    2,175

    Default Re: Using OpenOffice to edit DB entries (via TSV export)

    Import the changed file in PFM 1.5.9, but I do not see any changes.


    Can you tell me why?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •