A small micro-service for parsing the RAW-EXD generated by SaintCoinach. The data can also pulled from the FFXIV-Datamining Repository.
This repo should be considered abandoned, as an updated version of this is available and being updated over at Icarus Twine's repo.
- You will need PHP 7+ installed
- You will need Composer installed
git clone https://github.com/viion/saint-csv-parser-v2.git
cd saint-csv-parser-v2
composer install
php bin/console app:parse:csv [Project:Parse]
To use this tool you need to write a CSV Parsing file. The concept works around a Project Folder and a Parser File.
Start by creating a parser file, open up Command Prompt and cd
into the repository, then run the command:
php bin/console app:parse:create
$ php bin/console app:parse:create
SaintCoinach Parse Creator
==========================
What is your projects name? Eg: XIVDB:
> Hello
What would the parse be named? Eg: AchievementPoints:
> World
Generated file: /Users/josh.freeman/Misc/saint-csv-parser-v2/src/Parsers/Hello/World.php
Run as command: php bin/console app:parse:csv Hello:World
This will generate the file World.php
in the folder src/Parser/Hello
. This is where your code will live.
You can test run your parser straight away by running:
php bin/console app:parse:csv Hello:World
php bin/console app:parse:csv Hello:World
SaintCoinach CSV Parser
=======================
-------------- --------------------- -------------
MEMORY LIMIT START TIME PARSER
-------------- --------------------- -------------
2280M 2018-05-21 09:39:38 Hello:World
-------------- --------------------- -------------
RUN :: \App\Parsers\Hello\World
22600/22600 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
Saving data ...
Finished!
Duration: 2.223 seconds
Find your data in the /output folder
To begin editing your parser, open up the file:
- src/Parsers/{PROJECT}/{PARSER FILENAME}.php eg: src/Parsers/Hello/World.php
Some skeleton code is included to get you started.
$this->csv([filename])
Get a CSV file based on its exact filename, eg:
$itemCsv = $this->getCsvFile('Item');
This will provide some available properties:
$itemCsv->total
The total amount of rows in the CSV.$itemCsv->data
The data in the CSV that you can loop through.$itemCsv->content
The raw data in string format, no CSV processing.$itemCsv->columns
Get a list of column names in the CSV.$itemCsv->offsets
Get the offsets of the CSV file.$itemCsv->filename
Get the CSV filename.
Loop through data:
foreach ($itemCsv->data as $id => $row) {
$this->io->write('Item Name: '. $row['Name']);
}
$csv->at( ID )
If you are extending to other files and need a row at a specific id, you can use at()
, this will only work if the extended content (eg: $contentMemberTypeCsv
main ID
field represents the value you put in at(X)
.
For example, itemCsv->ItemLevel
links to the ItemLevel.csv file directly against the ID field, so you could do:
// $csv->at( ID )
$itemLevelRow = $itemLevelCsv->at($itemCsv['ItemLevel']);
$csv->find( COLUMN NAME , SEARCH VALUE )
If you need to find a row(s) to a specific value, you can use find()
, this is useful if there are multiple pieces of content with the same value in a specific column, provide the ColumnName
and the Value
to search for
// $csv->find( COLUMN NAME , SEARCH VALUE )
$conditions = $contentFinderConditionCsv->find('InstanceContent', $id);
$this->save( FILENAME , CHUNK SIZE [default: 200] , DATASET (default $this->data) )
Save the data that is in $this->data
to the specified filename, you can provide a chunk size (by default this is 200 rows), you can also overwrite the dataset if you want to be specific and not use $this->data
.
Data will end up in the /output
folder
// set some data
$this->data[] = "ItemName {$item->Name}";
// $this->save( FILENAME , CHUNK SIZE , OVERRIDE DATA)
$this->dump('ItemNames.txt');
*$this->io->XXX
Access the Symfony Console Input/Output commands, this can provide feedback and information to the output, you can find detailed documentation here: https://symfony.com/doc/current/console/style.html
The useful bits:
$this->io->progressStart(X);
Start a progress bar with X amount$this->io->progressAdvance();
Advance the progress bar by 1$this->io->progressFinish();
Complete the progress bar$this->io->text("hello world");
Write some text$this->io->section("My Awesome Section");
Write a section heading
Tables:
$this->io->table(
[ 'heading 1', 'heading 2', 'heading 3' ],
[
[ 'data 1', 'data 2', 'data 3' ],
[ 'data 1', 'data 2', 'data 3' ],
[ 'data 1', 'data 2', 'data 3' ],
]
);
php bin/console app:parse:clear-cache
Deletes everything in the /cache
folder.