Read file --> to CSV

Hi dear,

i’m allowing myself to ask your help for a script. My goal is very simlpe : browse the file in example (in the bottom) and take the part “PRICE_DATABASE” in a CSV file.

Result should look like this
Column A : Article → ART1
Column B : Prix → mr

each article (ART1, ART2 under “AH” have his price in “mr”

the file looks very close with JSON, but it’s not ! it’s LUA.

many thanks in advance.

[“items”] = {
[“isRecents”] = 1,
[“name”] = “Recherches récentes”,
}, – [1]
["__dbversion"] = 4,
[“AH”] = {
[“ART1”] = {
[“H3883”] = 1000000,
[“mr”] = 1000000,
[“ART2”] = {
[“H3883”] = 53000,
[“mr”] = 53000,

Welcome to the forum.

You forgot to post your script along with the sample data and where you’ve got stuck with your script. :wink:

If you don’t have anything to show yet and if theres no module or script out there at the internet you will have to create your own LUA parser probably.

I’d think you could start with Get-Content maybe …

… and with the -match comparison operator …

… or if the structure is consistent enough you could use Select-String with the parameter -Context

… to try to find the “ART..” keyswords and the following 2 lines and parse the file this way.

And BTW: At least for me it’s unclear what you meant with

Please post a sample snippet of the desired CSV file fitting the sample input data you posted.

When you post code, error messages, console ouput or sample data please format it as code using the “preformatted text” button ( </> )

Thanks in advance.

Edit #1:
Another approach could be to use Sophisitcated Techniques of Plain Text Parsing like Tobias explains it in this video:

Edit #2:
The next thought came to my mind is if this data comes from LUA it might not be the best idea to try to process them with PowerShell. There might be a way to get the data you’re after in a more common format in the first place. … like CSV or proper JSON or XML or YAML or anything less exotic than LUA. :wink: :smiley: