Results 1 to 2 of 2

Thread: Tool to convert export_descr_unit.txt & export_units.txt to .JSON

  1. #1
    Tyblitz's Avatar Foederatus
    Join Date
    Apr 2013
    Location
    Belgium
    Posts
    42

    Default Tool to convert export_descr_unit.txt & export_units.txt to .JSON

    Hi fellow (Rome) Total War fans,

    Some time ago I wanted to build a spreadsheet-like webpage for RTW & mod units.
    For this I had to go through an intermediary step of converting the plain .txt files to .json.

    Don't really know if anyone needs this right now, but I think it might come in handy sooner or later.
    Anyway, I present to you RTW JSON converter 1.0 (currently only working with export_descr_unit.txt & export_units.txt)

    RTW JSON converter 1.0

    What is this 'program'?
    This tool is an HTML webdocument that can convert export_units.txt & export_descr_unit.txt to .json
    or .jsonp (local json) files. These can be used in lots of applications as data feeds.

    Overview of the program
    Spoiler Alert, click show to read: 

    A small note on .json/ .jsonp files
    JSON stands for Javascript Object Notation and is a widely used plain text file exchange format, consisting of key/value pairs.
    JSON files can be parsed by a multitude of application & scripting languages,
    javascript being one of them, mostly for in-browser use. JSONP files are local JSON files.
    This means the browser's restrictions for cross-server requests are not as strict and allow
    using local .JSON files (without a server, i.e. a connection to internet).

    Use
    -----

    Download, unzip, then simply click the application icon and it will open in your default browser.
    If your default browser is not Google Chrome 30+, Opera 12.16+, Internet Explorer 11(Win7, allow 'blocked content' when prompted for) or Mozilla Firefox 25+,
    you will have to download one of these and launch it, then copy paste the application's Windows path to the http:// browser bar.
    In the latter case, please read the notes on compatibility carefully.

    The tool works with export_units.txt and export_descr_unit.txt from RTW vanilla, and also with Roma Surrectum II and Europa Barbarorum.
    So if you have another mod and your files have the same structure as one of these, they should be parsed correctly.


    This is what you get from a succesful conversion:

    Example of export_units_descr.txt before and after conversion
    Spoiler Alert, click show to read: 

    Although using the tool is pretty straightforward and information is available in the tool itself, here's basically what you have to do.

    1 - Load a plain text file (export_units.txt or export_descr_unit.txt atm)
    2 - choose ouput file type & format

    Type
    • export_units: List of unit short & long descriptions, and special abilities
    • export_descr_units: Traits of all units

    Format
    • .json: Regular .json file
    • .jsonp: Local .json file


    3 - choose output file structure

    Spoiler Alert, click show to read: 

    Available for export_units.txt & export_descr_unit.txt
    #1 - Original file structure - Preserve original file structure

    Available only for export_descr_unit.txt
    #2 -1faction/ unit, include all unit types: Replicate units n amount of times, with n = the amount of factions that have access to the unit.
    E.g. if a unit is owned by 3 factions, it will be replicated 3 times, each with one faction.
    #3 - 1faction/ unit, exclude ship & non-combatant units: Idem as #2 + Excludes ship units and civilian units (= units unavailable in real-time battles)
    #4 - 1faction/ unit, exclude non-combatant units: Idem as #2 + Excludes only civilian units (= units unavailable in real-time battles)


    4 - Convert file
    It is advised to eliminate all 'invisible' comments from the file (in the textfield) before
    proceeding to conversion. The parser will delete all newlines or lines starting with a semicolon,
    but will not distinguish regular phrases from data.

    5 - Save file
    • Save - Open a save prompt and save file directly to drive.
    • Select Text - Select the content inside the textfield. After this, make a new file
      (with extension .json/.jsonp), copy paste this content into it.


    Notes on Output
    ---------------------

    • export_descr_units: This file contains all the unit properties. In some cases (Europa Barbarorum I) there are multiple keys (2 or more officers per unit for example). The parser converts this in 'key0', 'key1', 'key2' etc.
    • export_unit: This file contains the lookup name, display name, long and short description of a unit. In the output the display name and lookup name are put in the same value ('dictionary', in analogy to export_descr_units' dictionary property), separated by a comma. Other properties don't change.


    Notes on compatibility
    ----------------------------

    v1.0 is compatible with browsers:
    • Google Chrome version 30 +
    • Internet Explorer 11 (Win7)
      Note:Allow 'Blocked Content' when prompted for or enable it in Internet properties
    • Mozilla Firefox 25 +
    • Opera 12.16 + (limited)
      Note: The 'Save' button doesn't work in Opera. Instead the user has to click the 'Select text' button,
      copy & paste the content in a blank text file, then rename it to <filename>.json/.jsonp.

    v1.0 is not compatible with browsers:
    • Internet Explorer
    • Safari
    • Google Chrome, Mozilla Firefox, Opera, Internet Explorer versions prior to the ones stated in 'compatible browsers'


    v1.0 is a 'beta' build and requires optimization, compatibility testing, and more format conversions.

    README file:

    Spoiler Alert, click show to read: 
    HTML Code:
    RTW JSON converter
    
    Version: 1.0
    Date: 04/12/2013
    Author: tyblitz
    Send feedback, comments & others to kevin.van.lierde@gmail.com
    
    Description
    -----------
    
    This tool is an HTML webdocument that can convert export_units.txt & export_descr_unit.txt to .json
    or .jsonp (local json) files. These can be used in lots of applications as data feeds. 
    You can use the tool by clicking on the shortcut, it will open in your default web browser.
    Read the notes on compatibility to know which web browsers it won't work on.
    
    JSON stands for Javascript Object Notation and is a widely used plain text file exchange format. 
    JSON files can be parsed by a multitude of application & scripting languages, 
    javascript being one of them, mostly for in-browser use. JSONP files are local JSON files. 
    This means the browser's restrictions for cross-server requests are not as strict and allow 
    using local .JSON files (without a server, i.e. a connection to internet).
    
    Use
    ---
    Simply click the application icon and it will open in your default browser. 
    If your default browser is not Google Chrome 30+, Opera 12.16+ or Mozilla Firefox 25+, 
    you will have to download one of these and launch it, then copy paste the application's Windows path to the http:// browser bar.
    In the latter case, please read the notes on compatibility carefully.
    
    1 - Load a plain text file (export_units.txt or export_descr_unit.txt)
    2 - choose ouput file type & format
    	* Type 	- export_units: List of unit short & long descriptions, and special abilities
    	* Format- export_descr_units: Traits of all units
    	
    3 - choose output file structure
    	Available for export_units.txt & export_descr_unit.txt
    	------------------------------------------------------
    	#1 	Original file structure - Preserve original file structure
    	
    	Available only for export_descr_unit.txt
    	----------------------------------------
    	#2 	1faction/ unit, include all unit types: Replicate units n amount of times, 
    			with n = the amount of factions that have access to the unit. 
    			E.g. if a unit is owned by 3 factions, it will be replicated 3 times, 
    			each with one faction.
    	#3 	1faction/ unit, exclude ship & non-combatant units: Idem as #2 +
    			Excludes ship units and civilian units (= units unavailable in real-time battles)
    	#4 	1faction/ unit, exclude non-combatant units: Idem as #2 +
    			Excludes only civilian units (= units unavailable in real-time battles)	
    	
    4  -  Convert file
    	It is advised to eliminate all 'invisible' comments from the file (in the textfield) before 
    	proceeding to conversion. The parser will delete all newlines or lines starting with a semicolon,
    	but will not distinguish regular phrases from data.
    
    5  -  Save file
    	* Save - Open a save prompt and save file directly to drive.
    	* Select Text - Select the content inside the textfield. After this, make a new file 
    		(with extension .json/.jsonp), copy paste this content into it.
    
    Notes on compatibility
    ----------------------
    
    v1.0 is compatible with browsers:
    	- Google Chrome version 30 +
    	- Internet Explorer 11 (Win7) +
    	- Mozilla Firefox 25 +
    	- Opera 12.16 + (limited)
    		Note: The 'Save' button doesn't work in Opera. Instead the user has to click the 'Select text' button,
    		copy & paste the content in a blank text file, then rename it to <filename>.json/.jsonp.
    
    v1.0 is not compatible with browsers:
    	- Safari
    	- Google Chrome, Internet Explorer, Mozilla Firefox, Opera versions prior to the ones stated in 'compatible browsers'.
    
    v1.0 is a 'beta' build and requires optimization, compatibility testing, and more format conversions.


    DOWNLOAD: RTW_JSON_Converter_1.0.zip

    Enjoy!

  2. #2

    Default Re: Tool to convert export_descr_unit.txt & export_units.txt to .JSON

    impressive work ++rep

Posting Permissions

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