FODSParser - Mini-IT/SnipeWiki GitHub Wiki
snipe.lib.FODSParser
is a class that parses .FODS file saved by OpenOffice Calc into a list of arrays of strings. You can have multiple tables on the same document page. We use it to upload the game balance tables into our projects. Calling ParserFODS.parseTables()
on a string with file contents will give you a list of structures that have table name, number of columns and a list of arrays of string for each row field. The table parsing starts with the cell containing the word "TABLE" in it. The next cell in the same row should hold the table name and the next one the number of columns in that table. The rows after that should hold the table contents.
Let's suppose you have the following file contents:
-- | a | b | c |
---|---|---|---|
1 | TABLE | Prizes | 3 |
2 | id | name | price |
3 | 1 | Money x10 | 10 |
4 | 2 | Money x100 | 100 |
5 | 3 | Money x200 | 200 |
The parser will look for the "TABLE" keyword on the page, and will treat that keyword as the start of the table. It will return the following object:
[{
name: "Prizes",
cols: 3,
rows: [ // rows will actually be a list, not an array
[ "id", "name", "price" ],
[ "1", "Money x10", "10" ],
[ "2", "Money x100", "100" ],
[ "3", "Money x200", "200" ]
]
}]