I am not too savvy with arrays and am assuming that what I am looking for needs arrays. This is my requirement.
So I have the raw data that gets updated to a log as shown below
[20171102 10:00:00] StudentInfo:
FullInfo = {
Address = Newark
Age = 20
Name= John
}
[20171102 10:00:00] StudentInfo:
FullInfo = {
Address = NYC
Age = 22
Name = Mary
}
There are blocks of data in the sense, a block starts from '[' and closes at '}'. So from the above there are 2 blocks.
The fields are what appears between '{' and '}'. These fields are not fixed, in the sense, i will run the script and supply the fields, sometimes I will supply say 3 fields - Address, Age and Name and other times more or less.
Can a script be made to parse this data and output the data into csv?
So the output for the above would look as
DateTime Address Age Name
20171102 10:00:00 Newark 20 John
20171102 10:00:00 NYC 22 Mary
If i had say another field supplied say Subject, then the output would be
[20171102 10:00:00] StudentInfo:
FullInfo = {
Address = Newark
Age = 20
Name = John
Subject = Math
}
[20171102 10:00:00] StudentInfo:
FullInfo = {
Address = NYC
Age = 22
Name = Mary
Subject = Literature
}
I would the output in csv as
DateTime Address Age Name Subject
20171102 10:00:00 Newark 20 John Math
20171102 10:00:00 NYC 22 Mary Literature
Please can some one advise. The farthest I have got is doing awk and parsing the data, but I dont know how to call it by block and the align it in columns