Hi Nitin,

Are you trying to do this conversion in JavaScript, or on your server?

Parsing a CSV file as simple as this one is trivial, in JavaScript or in any
reasonable server language. (BTW, you wouldn't convert it to JSON, but to a
two-dimensional array.) Ah... I just checked your bytes.com post - the
csvArray() funcition you have there is along the right lines.

But if you're trying to do this in JavaScript in the browser, there is a
much bigger problem: How are you going to retrieve the data at all?
Cross-domain restrictions will prevent you from fetching it. Do you actually
get any thing back from your $.get()?

If you have to do this in JavaScript, does Google Finance offer a JSONP
output format option? That will work cross-domain.

Also, your ConvertToArray function in your bytes.com post can't possibly
work. This function is called in the $.get() callback, long after the page
has finished loading. But it calls document.write(), which you can only call
*while* the page is loading.

-Mike

> From: Nitin Sawant
> 
> Hello,
>       Thanks for your reply.
> 
>       Actually i'm retrieving data from google finance site 
> in csv format. 
> http://finance.google.com/finance/historical?q=GOOG&startdate=
> May+1%2C+2009&enddate=May+5%2C+2009&start=225&num=25&output=csv
>       I want to convert that data to json or any suitable 
> format on webpage so that i can show stock quote chart on the 
> page using that data.
> 
> regards,
> Nitin Sawant
> 
> On May 20, 7:45 pm, brian <bally.z...@gmail.com> wrote:
> > There's quite a difference between the two. JSON uses a key: value 
> > format, while CSV is generally value only
> >
> >
> >
> > On Wed, May 20, 2009 at 6:28 AM, Nitin Sawant 
> <nitin.jays...@gmail.com> wrote:
> >
> > > How to convert csv file to json using jquery / javascript??
> 

Reply via email to