Datetime format in CSV

317 views
Skip to first unread message

K. Anthony

unread,
Oct 15, 2015, 3:10:45 PM10/15/15
to Google Visualization API
I am experimenting with trying to create a timeline chart using data in a CSV file, as we want to be able to more easily expand the visualization as more data comes in. I'm coming up against a Invalid data table format: column #2 must be of type 'date,number,datetime'. error. I've read up in this forum and it seems like there might be an issue in parsing the datetime format as it is read as a string? Is there any way around this issue or should we continue to put data in the chart html? Or would JSON work?

Sergey Grabkovsky

unread,
Oct 15, 2015, 3:42:17 PM10/15/15
to Google Visualization API
Hi Anthony,

The JSON format will encode type information and has proper support for dates, so using that is definitely preferred. I was under the impression that dates worked with CSV, but I could be wrong about that. If you could link to a test page, I could tell you for sure.

On Thu, Oct 15, 2015 at 3:10 PM K. Anthony <anthk...@gmail.com> wrote:
I am experimenting with trying to create a timeline chart using data in a CSV file, as we want to be able to more easily expand the visualization as more data comes in. I'm coming up against a Invalid data table format: column #2 must be of type 'date,number,datetime'. error. I've read up in this forum and it seems like there might be an issue in parsing the datetime format as it is read as a string? Is there any way around this issue or should we continue to put data in the chart html? Or would JSON work?

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/097dd41a-6025-4c56-98df-3c6c1e610453%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

K. Anthony

unread,
Oct 15, 2015, 3:57:54 PM10/15/15
to Google Visualization API
Thanks Sergey,

Sergey Grabkovsky

unread,
Oct 15, 2015, 4:28:14 PM10/15/15
to Google Visualization API
Oh, you're using jQuery to parse the CSV. You'll need to be aware of which columns are dates and do the correct thing to convert it yourself.

Alternatively, you could use our Query to fetch your CSV. There was a thread about it a while ago, which you can find here.

However, I'd be careful with using dropbox as your content server. We append some URL parameters, which appears to cause dropbox to redirect, which we do not support. But if you host the file somewhere that just ignores extra URL parameters, you shouldn't have any issues.

On Thu, Oct 15, 2015 at 3:57 PM K. Anthony <anthk...@gmail.com> wrote:
Thanks Sergey,

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.

K. Anthony

unread,
Oct 15, 2015, 4:49:25 PM10/15/15
to Google Visualization API
Dropbox is definitely not a permanent solution but when I tried to point to a file on my computer in the same folder, I experienced a cross origin request error.

I'll definitely try with the query option next (thanks for the thread link), but regarding the jQuery I'm using now, I still don't understand what I'm doing wrong. I've tried to format the date about 5 different ways based on google searches but nothing works. What is the right way to format datetime? Here's what I have currently, based (I think) on what I say in the documentation)

Student 569,Pretest,08-14-2015T02:05:00-0600,08-14-2015T02:10:00-0600
Student 569,Supplemental Info,08-14-2015T02:10:15-0600,08-14-2015T02:10:21-0600


Sergey Grabkovsky

unread,
Oct 15, 2015, 5:01:51 PM10/15/15
to Google Visualization API
It's not about the "right" way of formatting the date. As far as I know, jQuery doesn't have any implicit support for dates. That is, it doesn't detect that something is a date and then converts it from a string. You will have to do that yourself, manually. You know that your 3rd and 4th columns will be dates, so you will have to write logic to parse them yourself.

Our CSV processing does support dates automatically, however. That's why I was suggesting it.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.

K. Anthony

unread,
Oct 15, 2015, 5:28:08 PM10/15/15
to Google Visualization API
Oh, got it! I'll try the query method then. Thanks so much!
Reply all
Reply to author
Forward
0 new messages