create a plain text table

L

Larry

I am really at a loss with the following. I have a big multidimendionas hash
made up like this:

$OI->{"dd/mm/yyyy"}->{"name"}->{"expire date"}->{"strike"}->{"type"} =
num_val

where TYPE can ben "Call" or "Put" and STRIKE is a numeric value.

I fill in that hash by parsing an xml file like this:

....
<OI date="04/10/2010" name="AAPL" exp_date="DEC2010" strike="320" call="30"
put="50" />
<OI date="04/10/2010" name="AAPL" exp_date="DEC2010" strike="320" call="100"
put="172" />
....

I need to create a table (plain text) out of that hash, something as follows

name: ( #workbook
expire date: ( #worksheet 1
strike type dd/mm/yyyy dd/mm/yyyy dd/mm/yyyy ..etc..

15 Call num_val num_val num_val
15 Put num_val num_val num_val

16 Call num_val num_val num_val
16 Put num_val num_val num_val

..etc..

)

expire date: ( #worksheet2
strike type dd/mm/yyyy dd/mm/yyyy dd/mm/yyyy ..etc..

15 Call num_val num_val num_val
15 Put num_val num_val num_val

16 Call num_val num_val num_val
16 Put num_val num_val num_val

..etc..

)
)

basicaly the STRIKE field is supposed to be sorted by ascending
and the DD/MM/YYYY is supposed to be sorted by older->newer

Any help will be appreciated on how to go about making that possible in
Perl!

thanks
 
C

C.DeRykus

I am really at a loss with the following. I have a big multidimendionas hash
made up like this:

$OI->{"dd/mm/yyyy"}->{"name"}->{"expire date"}->{"strike"}->{"type"} =
num_val

where TYPE can ben "Call" or "Put" and STRIKE is a numeric value.

I fill in that hash by parsing an xml file like this:

...
<OI date="04/10/2010" name="AAPL" exp_date="DEC2010" strike="320"call="30"
put="50" />
<OI date="04/10/2010" name="AAPL" exp_date="DEC2010" strike="320"call="100"
put="172" />
...

I need to create a table (plain text) out of that hash, something as follows

name: ( #workbook
   expire date: ( #worksheet 1
      strike  type  dd/mm/yyyy  dd/mm/yyyy  dd/mm/yyyy  ...etc..

      15      Call  num_val     num_val     num_val
      15      Put   num_val     num_val     num_val

      16      Call  num_val     num_val     num_val
      16      Put   num_val     num_val     num_val

      ..etc..

   )

   expire date: ( #worksheet2
      strike  type  dd/mm/yyyy  dd/mm/yyyy  dd/mm/yyyy  ...etc..

      15      Call  num_val     num_val     num_val
      15      Put   num_val     num_val     num_val

      16      Call  num_val     num_val     num_val
      16      Put   num_val     num_val     num_val

      ..etc..

   )
)

basicaly the STRIKE field is supposed to be sorted by ascending
and the DD/MM/YYYY is supposed to be sorted by older->newer

Any help will be appreciated on how to go about making that possible in
Perl!

Are you looking for help in walking through
the data structure, sorting, or formatting
the output table...?

Have you researched Perl's online docs:
perldoc perldsc
perldoc -f sort
perldoc -f printf
perldoc perlform


CPAN: Text::Table is another possibility for
output formatting.
 
L

Larry

Larry said:
I am really at a loss with the following. I have a big multidimendionas
hash made up like this:

$OI->{"dd/mm/yyyy"}->{"name"}->{"expire date"}->{"strike"}->{"type"} =
num_val

where TYPE can ben "Call" or "Put" and STRIKE is a numeric value.

I fill in that hash by parsing an xml file like this:

...
<OI date="04/10/2010" name="AAPL" exp_date="DEC2010" strike="320"
call="30" put="50" />
<OI date="04/10/2010" name="AAPL" exp_date="DEC2010" strike="320"
call="100" put="172" />
...

I need to create a table (plain text) out of that hash, something as
follows

name: ( #workbook
expire date: ( #worksheet 1
strike type dd/mm/yyyy dd/mm/yyyy dd/mm/yyyy ..etc..

15 Call num_val num_val num_val
15 Put num_val num_val num_val

16 Call num_val num_val num_val
16 Put num_val num_val num_val

..etc..

)

expire date: ( #worksheet2
strike type dd/mm/yyyy dd/mm/yyyy dd/mm/yyyy ..etc..

15 Call num_val num_val num_val
15 Put num_val num_val num_val

16 Call num_val num_val num_val
16 Put num_val num_val num_val

..etc..

)
)

basicaly the STRIKE field is supposed to be sorted by ascending
and the DD/MM/YYYY is supposed to be sorted by older->newer

Any help will be appreciated on how to go about making that possible in
Perl!

thanks

I think I'll stick with DBI and SQLite...
 
D

Dr.Ruud

$OI->{"dd/mm/yyyy"} ...

Just a weekend thought:

When I see something like that, I stop reading. I really dislike it when
the display level creeps into the code like that.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top