3 Replies - 266 Views - Last Post: 11 July 2014 - 12:04 PM Rate Topic: -----

#1 ixoye800  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 20-June 09

Best way to store a multi-dimensional array with unknown bounds?

Posted 11 July 2014 - 11:39 AM

I'm trying to store content scraped from several lyric and chord websites into separate variables into either a multi-dimensional array, or into separate string arrays, but I've been stuck trying some different approaches. I've searched through the site and have found many questions that were similar, though incompatible or difficult to adapt with my project.

If content was stored in a multi-dimensional array, it would look like this:

Search Site > Artist > Link to artist page > Song > Link to song page > Tab types (Chords, Lyrics, Tabs) > Link to tab type (Chords, Lyrics, Tabs) > Content

A good visual representation of this array would look like this: Posted Image

Keep in mind the content is dynamic, so it is not possible for me to hard-code array bounds without first retrieving the size of the content I'm storing (e.g. amount of songs per artist)

Below are the approaches I've tried and their shortcomings, or where I failed to implement correctly:

Multi-dimensional (jagged) arrays required explicit bounds, and only the rightmost array can be resized. (This approach can be made to work by setting explicit bounds after all content has been captured, but creating temporary variables and passing them all to the multi-dimensional array requires a lot of code and seems like a "dirty" solution to my problem.)

Tuples seemed promising, but for some reason, I was not able to create a tuple containing different variable types, or the approach was confusing.

Individual arrays did not give me enough flexibility and required creating multiple new arrays dynamically. (e.g. an array for the list of songs for a specific artist, another for the tab links in a specific song, etc.)

I'm sure I've tried others, but I cannot remember at the moment, I've seen a similar approach done with Structures on a sample for a user control here and others who implemented a local database to contain all the elements.

All that is needed is an approach that is simplistic but functional.

Any help is gladly appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Best way to store a multi-dimensional array with unknown bounds?

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9195
  • View blog
  • Posts: 34,516
  • Joined: 12-June 08

Re: Best way to store a multi-dimensional array with unknown bounds?

Posted 11 July 2014 - 11:43 AM

Quote

I'm trying to store content scraped from several lyric and chord websites

Obligatory - I hope this is okay with their terms of service/use.


Why not impose a relational database structure on it? Things have IDs.. IDs help track what is part of what.. etc. Data sets and data tables..
Was This Post Helpful? 0
  • +
  • -

#3 ixoye800  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 20-June 09

Re: Best way to store a multi-dimensional array with unknown bounds?

Posted 11 July 2014 - 12:01 PM

View Postmodi123_1, on 11 July 2014 - 12:43 PM, said:

Quote

I'm trying to store content scraped from several lyric and chord websites

Obligatory - I hope this is okay with their terms of service/use.


Thanks for the heads-up. I will check those sites for their Terms of Service. Regardless, I'm going to be doing this purely for personal purposes and all pages scraped will contain a 'copyrighted by site' watermark.

View Postmodi123_1, on 11 July 2014 - 12:43 PM, said:

Why not impose a relational database structure on it? Things have IDs.. IDs help track what is part of what.. etc. Data sets and data tables..


This sounds like it might be what I need. What's the best way to implement this in WPF/VB.Net? Do you know of any sample code I could look at to try to add this into my project?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9195
  • View blog
  • Posts: 34,516
  • Joined: 12-June 08

Re: Best way to store a multi-dimensional array with unknown bounds?

Posted 11 July 2014 - 12:04 PM

Quote

Thanks for the heads-up. I will check those sites for their Terms of Service. Regardless, I'm going to be doing this purely for personal purposes and all pages scraped will contain a 'copyrighted by site' watermark.

No problem.

Though 'for personal purposes' this may be, but I frown on folks trampling other terms of use regardless of the intention.



Check the database section/tutorials.. and the VB.NET tutorials/snippets have code on interacting with the database. As for learning about relational database that's a bit of a more broad topic, but certainly topics out there for it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1