Converting lua to excel file?
Anyone has a tutorial or link that shows me how I can convert data stored in savedvariabels to an excel database?
Tx |
You can't easily do an export of LUA file with ESOUI, because the only way to write something on the disk is to pass trought SavedVars, so you'll need another scripting language (it's really really faster). Here you can write this script in any language, you only need to pass as arg the text in the saved file or thhe file itself.
Then this scripting language must convert the file into something your other tool (here, Excel) can understand. I suggest you to use JSON format, because converting from LUA to JSON is really easy. Then use a convert tool to import this format into excel. I quickly looked at XML, but it looks little bit harder. Here is a quick script (in php) which convert LUA into JSON, I think you can easily adapt the format to C#, perl, ruby or anything else. I didn't look if you can have problems with special chars if you export strings, but it shouldn't be complicated to protect strings with this format. For private and little use, I strongly suggest you to use something more "human compliant" : Notepad++, Delete button, Ctrl+H, etc. Code:
function convert($luaText) |
Quote:
My current addon does this every time it's run (GSA) -- it is the only way to get data from "in game" to an external program. Mine creates a database. depending on the addon you are trying to do this with I could just give you my 100% working subroutine and with a few minor changes it would work as a VBS. It's basically - open .lua file read line by line trim spaces - check if it's something you are trying to keep if yes add it to a string + "," decide when to insert a line break repeat until EOF when done write all to a .csv there are certain tricks to making it more efficient like If InStr(line, "},") > 0 or If InStr(line, "{,") > 0 then ignore and read next line -d |
If you want to do it the "right" way, you should use a lua script outside of the game to load the savevars file and export it into the required form from there.
A short search on google shows that there is a library that allows you to create excel files from lua, which should make this rather easy. But in the end it depends on what you plan to do. If you want to use it for an addon, it will probably be more user friendly if you just write your own program and don't force users to install a lua interpreter. Regardless of the method you choose, you will need to 1) somehow get the data out of the game client (-> saved variables) 2) read the exported data (-> anything that can read files will do) 3) parse it (-> depends on how you structured the data before you exported it) 4) put it wherever you want to have it (-> excel) |
Quote:
I have already done what she asked - it's ESO LUA savariables to csv. An example from one sale is... from saved variables... Code:
["SalesData"] = my program produces... Code:
Black Market Traders,iron sabatons,1,1416586399,350,@FootJuice,@dOpiate,1:0:1:12 It works flawlessly. there are 700+ GSA users and I'm getting no complainants - and since I check and re-check for new items I have routines to weed out duplicates. Anyway -- I guess we aren't clear on exactly what she wants until she replies. -d |
The saved vars file is lua source code. :confused:
It defines a global table when you load it, so you don't even have to parse it, you can simply use it the way it is. Combined with the library mentioned in the linked SO answer, you can just load the saved vars file and write it to an excel file. I know that your way works too, but the safest and easiest way to read a lua file will always be to load it in lua ;) |
Quote:
-d |
My programming exercise
I'm not sure if anyone cares - but as a programming exercise (slow day at work) I made a quick little saved variables parser.
It grabs all the variable names and splits them into two lists - ones that contain data and ones that don't It doesn't output anything but it could be configure to do any number of things. You can multi-select from either list. I put the exe and the form1.vb (all the actual code) in the zip. Maybe it will spark an idea in someone or give someone a head start trying to parse the important variabls from a LUA file. Here is an example - I opened the saved variables file for Combat Log Stats The title on the GUI is incorrect because it doesn't create a csv -- I was just trying some things at work (sneaking in the coding) As I said the code is in the zip also. -d |
All times are GMT -6. The time now is 09:59 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI