lightswitch05 / table-to-json

Serializes HTML tables into JSON objects.
http://lightswitch05.github.io/table-to-json/
MIT License
756 stars 172 forks source link

Extract values by column #21

Closed pakal closed 8 years ago

pakal commented 9 years ago

Currently, tabletojson follows the row-oriented approach of HTML ; what's the easiest path if one wants to convert a table column by columb first, by keeping the behaviour of the plugin intact (auto extraction of hash dicts from first row/col etc.) ?

Can it be done by preprocessing or post-processing the data ? Or does it require a heavy evolution of the plugin (I don't easily see, with the current code, how much work it asks for) ?

lightswitch05 commented 9 years ago

Before I answer your question, I want to make sure I understand it first.

You want to turn the current example:

table == [{"First Name"=>"Jill", "Last Name"=>"Smith",   "Score"=>"disqualified"},
          {"First Name"=>"Eve",  "Last Name"=>"Jackson", "Score"=>"94"},
          {"First Name"=>"John", "Last Name"=>"Doe",     "Score"=>"80"},
          {"First Name"=>"Adam", "Last Name"=>"Johnson", "Score"=>"67"}]

Into:

table == {"First Name"=>["Jill", "Eve", "John", "Adam"],
          "Last Name"=>["Smith", "Jackson", "Doe", "Johnson"],
          "Score"=>["disqualified", "94", "80", "67"]}

Right? Are you going to be using Table-to-json on a website that you own and can modify?

lightswitch05 commented 8 years ago

Closing this issue due to inactivity

mschultheiss83 commented 8 years ago

hint use lodash or underscore for transformations