# Problem in Hash formatted output

**URL:** <https://www.ruby-forum.com/t/problem-in-hash-formatted-output/154426>\
**Category:** Ruby\
**Created:** [November 29, 2008, 11:50am UTC](https://www.ruby-forum.com/t/problem-in-hash-formatted-output/154426 "2008-11-29T11:50:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jazzezravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jazzezravi](https://www.ruby-forum.com/u/jazzezravi)\
**Post date:** [November 29, 2008, 11:50am UTC](https://www.ruby-forum.com/t/problem-in-hash-formatted-output/154426/1 "2008-11-29T11:50:52Z")

</div>

Hi All,

I have an Array Like this

@output=[{“accounts”=\>[“id”, “group\_id”, “company\_id”, “number”, “name”,  
“opening\_balance”, “description”, “editable”, “created\_at”,  
“updated\_at”, “source\_account”, “deleted\_status”, “alias”,  
“closing\_balance”, “flag”]},

{“blogs”=\>[“id”, “category\_id”, “title”, “content”, “views”,  
“created\_at”, “updated\_at”]},

{“categories”=\>[“id”, “name”]}  
{“clients”=\>[“id”, “first\_name”, “last\_name”, “street1”, “street2”,  
“city”, “state”, “zip”, “country”, “phone”, “fax”, “email”, “website”,  
“flag”, “created\_at”, “updated\_at”]},

{“companies”=\>[“id”, “client\_id”, “name”, “street1”, “street2”, “city”,  
“state”, “zip”, “country”, “phone”, “fax”, “email”, “website”, “flag”,  
“created\_at”, “updated\_at”, “business\_number”, “year\_end\_date”,  
“net\_days”, “selected\_province”, “tax”, “plan\_name”, “error\_display”,  
“logo\_display\_flag”, “business\_type”, “user\_id”]},

{“company\_details”=\>[“id”, “content\_type”, “filename”, “size”,  
“parent\_id”, “thumbnail”, “width”, “height”, “db\_file\_id”,  
“attachable\_type”, “attachable\_id”]},

{“contacts”=\>[“id”, “company\_id”, “company\_name”, “first\_name”,  
“last\_name”, “title”, “street1”, “street2”, “city”, “state”, “zip”,  
“country”, “phone”, “email”, “fax”, “website”, “contact\_type”,  
“created\_at”, “updated\_at”, “account\_id”, “flag”]},

{“countries”=\>[“id”, “name”, “code”]}]

This is my array. I want to get exactly like this Output format

OUTPUT:

## 01.accounts id group\_id company\_id number name opening\_balance description editable created\_at updated\_at source\_account deleted\_status alias closing\_balance flag

## 02.blogs id category\_id title content views created\_at updated\_at

AND So ON

Please provide a code for it

Thanks,  
P.Raveendran

> **[Raveendran](https://raveendran.wordpress.com)**
>
> Nothing is impossible...

---

<div class="post-metadata">

**Author:** ![jazzezravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jazzezravi](https://www.ruby-forum.com/u/jazzezravi)\
**Post date:** [November 29, 2008, 12:41pm UTC](https://www.ruby-forum.com/t/problem-in-hash-formatted-output/154426/2 "2008-11-29T12:41:47Z")

</div>

On 29.11.2008 11:45, jazzez ravi wrote:

> I have an Array Like this

> This is my array. I want to get exactly like this Output format

> Please provide a code for it

Another attempt to abuse the community to write code for free. For this  
to work you should provide a much more interesting problem than  
formatting output of a nested data structure.

Alternative show the code you have got so far and we’ll be happily  
helping out where you have problems.

Regards

robert

---

<div class="post-metadata">

**Author:** ![jazzezravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jazzezravi](https://www.ruby-forum.com/u/jazzezravi)\
**Post date:** [November 29, 2008, 3:02pm UTC](https://www.ruby-forum.com/t/problem-in-hash-formatted-output/154426/3 "2008-11-29T15:02:16Z")

</div>

jazzez ravi wrote:

> Hi All,
> 
> I have an Array Like this  
> _snip_  
> This is my array. I want to get exactly like this Output format  
> _snip_  
> Please provide a code for it

There is a difference between _help_ and _solutions_. Help you might get  
for free here (depends a lot on you, e.g. attitude, proper information  
etc.), but if you want solutions, go and get some contractor. That’s  
what you _pay_ for.

Regards  
Stefan

---

<div class="post-metadata">

**Author:** ![jazzezravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jazzezravi](https://www.ruby-forum.com/u/jazzezravi)\
**Post date:** [November 30, 2008, 10:42pm UTC](https://www.ruby-forum.com/t/problem-in-hash-formatted-output/154426/4 "2008-11-30T22:42:17Z")

</div>

Stefan R. wrote:

> jazzez ravi wrote:
> 
> > Hi All,
> > 
> > I have an Array Like this  
> > _snip_  
> > This is my array. I want to get exactly like this Output format  
> > _snip_  
> > Please provide a code for it
> 
> There is a difference between _help_ and _solutions_. Help you might get  
> for free here (depends a lot on you, e.g. attitude, proper information  
> etc.), but if you want solutions, go and get some contractor. That’s  
> what you _pay_ for.

2 jazzez ravi =\>  
agreed 🙂

2 Stefan R. =\>  
what for do you need this  
for debugging reason you may use ‘pp’  
eg. require ‘pp’; pp @output

else you have to write your own method if you need this being  
implemented  
a lot of samples exist in the network, just carefully dig

---

<div class="post-metadata">

**Author:** ![jazzezravi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/71e660/32.png) [@jazzezravi](https://www.ruby-forum.com/u/jazzezravi)\
**Post date:** [December 1, 2008, 5:07am UTC](https://www.ruby-forum.com/t/problem-in-hash-formatted-output/154426/5 "2008-12-01T05:07:29Z")

</div>

Hi All,

Thanks for your kind information. I requested to my client for provide a  
full code to me. And also suggest the output format like this,

accounts=[“id”,  
“group\_id”,  
“company\_id”,  
“number”,  
" name",  
" opening\_balance",  
" description",  
" editable",  
" updated\_at",  
" source\_account",  
" deleted\_status",  
" alias",  
" closing\_balance",  
" flag"]

output=[accounts,blogs]

I have only the above output format which is mentioned the Top of the  
Post.Thats why asking suggestion from U Guys. Anyway let u know after  
getting info from My client.

Thanks,  
P.Raveendran  
[http://raveendran.wordpress.com](http://raveendran.wordpress.com)
