0

I am trying to read this link

http://archive.ics.uci.edu/ml/machine-learning-databases/semeion/semeion.data

and format it and store it in 1593x256 array, so I can apply some ML techniques on it and play with it. Any ideas how to grab the data ? maybe jquery has something?

Sirko
  • 72,589
  • 19
  • 149
  • 183
Test Test
  • 2,831
  • 8
  • 44
  • 64
  • 1
    Little more information on your problem would be good. Is the question how to retrieve the data? How to reformat it? How to save to the array? Have you started yet, is there some specific point you are stuck at? In total: What's the next step you want to take and what's your precise problem with it. – Henrik Mühe Sep 28 '12 at 10:23
  • I just want to store it in a variable, and then reformat the string into something I want and store it in a variable – Test Test Sep 28 '12 at 10:33

1 Answers1

1

From your question I gather that you are wondering how to actually get the data, that is fetch the URL and put the contents in a string variable in javascript so as to continue processing it. For this, http://api.jquery.com/jQuery.ajax/ should be of value.

Numerous examples are given in the documentation, a simple one would be

$.ajax({
  url: "http://archive.ics.uci.edu/ml/machine-learning-databases/semeion/semeion.data",
}).done(function(content) {
  // do something with the content
});

Keep in mind though that trying to execute something like this from a web application requires the server you are hosting your website add to allow cross domain ajax, see for instance http://usejquery.com/posts/the-jquery-cross-domain-ajax-guide for info on that.

Parsing the data can be accomplished by iterating over the string, splitting it into an array by lines and then splitting each line into columns. If you do not want to write that code yourself, a number of pointers are given here Javascript code to parse CSV data - specifically, JQuery-cvs seems to be configurable to exactly suit your needs.

Community
  • 1
  • 1
Henrik Mühe
  • 419
  • 3
  • 24