I have some files which has data in the hash format which I am trying to print as tabular format,
{
:outerkey1 => "value1",
:innerhash => {
:doubleinnerhash => {
:key1 => "",
:key2 => true,
:key3 => 0,
:key4 => "line1\nline2\n line3\nline4\n"
},
:innerkey => "OK",
:innerkey3 => 0
},
:outerkey2 => "value2",
:outerkye3 => "value3",
:outerkey4 => "value4"
}
In the above formatted data, wanted to parse outerkey
and the hash value of doubleinnerhash
and then print in the tabluar format to present it.
I have got some idea on Python with the help of Python - Printing a dictionary as a horizontal table with headers but if want to implement then I need to convert this Ruby hash to Python Dict format where will get data inconsistency issue.
Am expecting below formatted output,
|----------------------------------------------------|
|outerkey1 | key1 | key2 | key3 | key4 |
|----------------------------------------------------|
|value1 | | true | 0 | line1|
| | | | | line2|
| | | | | line3|
| | | | | line4|
|----------------------------------------------------|
|value2 |error | false | 2 | line1|
| | | | | line2|
| | | | | line3|
| | | | | line4|
|----------------------------------------------------|
So is there any straight forward mechanism to make this work in Ruby?