A few days ago I was working on manipulating data that I found in Wikipedia. The data was in a table where the colspans and rowspans were making it difficult to simply programmatically pull data. Then I started looking into code to turn HTML table to JSON but for some reason the rowspans were still causing issues. Finally, I decided to just write a quick and dirty function to get the job done:

The cool thing about this function is that in the case of cells that span multiple columns and/or rows the value in that cell will be written to each corresponding sub-array value.


1 Comment

HyukOh · April 17, 2018 at 8:48 PM

I did the same thing from scratch few month ago. But your code is much better! I should’ve google it more. : (

Leave a Reply

Your email address will not be published. Required fields are marked *