mc0rp
March 25, 2016, 1:16pm
1
Hi,
Apologies if answered already somewhere here, I've searched the forum and couldn't find it though...
I'm trying to transform a structured text file - not any well-known formats like json, xml etc., but well-structured:
level1 <name1>
Level1_1 <name1_1>
var1 set <value1>
var2 set <value2>
endlevel
Level1_2 <name1_2>
var1 set <value3>
var2 set <value4>
endlevel
Leveln_m <namen_m>
varx <valuey>
endlevel
endlevel
How to transform it into table where the rows are grouped by Leveln, then Leveln_m and columns are values respectively?
I'm not a programmer, although familiar with simple programming, so I'd appreciate help for not-so-stupid-but-not-a-coder ;-)
TiA
Marcin
Hello Marcin,
I'm not quite sure how your output table should look like. Can you provide the table to your text-example?
Thank you,
Ferry
mc0rp
March 31, 2016, 3:52pm
3
Hey Ferry,
I would take something like:
or:
or CSV like this:
_________________________________
Level1,Level1_1,var1,value1;
Level1,Level1_1,var2,value2;
Level1,Level1_2,var1,value1;
Level1,Level1_2,var2,value2;
...
_________________________________
Thanx,
Marcin
Geo
April 1, 2016, 1:55am
4
There are at least two ways to tackle the problem, unfortunately none of them are trivial absent the JSON or XML format:
1) transform your structured text file such that it will look like JSON format so to finally be able to use JSON Path - this requires alot of text parsing nodes (String Manipulation) ;
2) walk through each line, as many times as you have levels and to extract the var-value pairs directly - here you'll need to come up with an algorithm to extract the parent level information from each line;
mc0rp
April 1, 2016, 11:09am
5
Geo,
Thanx, I was suspecting it wouldn't be easy :(
Although arduous, the second looks promising, I'll have to get my hands dirty, since there's no alternative...
Marcin
It might be a little to late for Marcin, but for the reference here is a workflow that does what you were looking for.
Best,
Ferry
system
Closed
June 2, 2023, 9:48pm
7
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.