CustomJS to create a csv

Hello,

I have been trying to generate a csv file as per the https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv

I have created a get_csv.js file as per the example and modified for my 2 columns Name, Quantity:

get_csv.js

var data = source_locate.data;
var filetext = 'Name,Quantity\n';
for (i=0; i < data['Name'].length; i++) {
    var currRow = [data['Name'][i].toString(),
                   data['Quantity'][i].toString()];

    var joined = currRow.join();
    filetext = filetext.concat(joined);
}

var filename = 'test.csv';
var blob = new Blob([filetext], { type: 'text/csv;charset=utf-8;' });

//addresses IE
if (navigator.msSaveBlob) {
    navigator.msSaveBlob(blob, filename);
}

else {
    var link = document.createElement("a");
    link = document.createElement('a')
    link.href = URL.createObjectURL(blob);
    link.download = filename
    link.target = "_blank";
    link.style.visibility = 'hidden';
    link.dispatchEvent(new MouseEvent('click'))
}

In main.py, I have :

source_locate = ColumnDataSource(data=dict(Name=,Quantity=))
source_locate.data = source.from_df( a python function that returns a dataframe)

button.callback = CustomJS(args=dict(source=source_locate),code = open(join(dirname(__file__), "get_csv.js")).read())

I do get this as on output from source_locate.data -->{'Name': ['A', 'B', 'C'], 'Quantity': [-14778600, -5471100, -52030900]}
so it seems to work but the CustomJS does not execute when I click on the button..

Thanks a lot for your help or for any feedbacks that can put me in the right direction…

Best and Happy new year to the all team.

Bokeh is amazing

Even, I am facing exactly this issue. @Bryan, can you help us out here.

Thanks!

···

On Friday, 30 December 2016 13:19:20 UTC-5, PH wrote:

Hello,

I have been trying to generate a csv file as per the https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv

I have created a get_csv.js file as per the example and modified for my 2 columns Name, Quantity:

get_csv.js

var data = source_locate.data;
var filetext = 'Name,Quantity\n';
for (i=0; i < data['Name'].length; i++) {
    var currRow = [data['Name'][i].toString(),
                   data['Quantity'][i].toString()];

    var joined = currRow.join();
    filetext = filetext.concat(joined);
}

var filename = 'test.csv';
var blob = new Blob([filetext], { type: 'text/csv;charset=utf-8;' });

//addresses IE
if (navigator.msSaveBlob) {
    navigator.msSaveBlob(blob, filename);
}

else {
    var link = document.createElement("a");
    link = document.createElement('a')
    link.href = URL.createObjectURL(blob);
    link.download = filename
    link.target = "_blank";
    link.style.visibility = 'hidden';
    link.dispatchEvent(new MouseEvent('click'))
}

In main.py, I have :

source_locate = ColumnDataSource(data=dict(Name=,Quantity=))
source_locate.data = source.from_df( a python function that returns a dataframe)

button.callback = CustomJS(args=dict(source=source_locate),code = open(join(dirname(__file__), "get_csv.js")).read())


I do get this as on output from source_locate.data -->{'Name': ['A', 'B', 'C'], 'Quantity': [-14778600, -5471100, -52030900]}
so it seems to work but the CustomJS does not execute when I click on the button..


Thanks a lot for your help or for any feedbacks that can put me in the right direction…

Best and Happy new year to the all team.

Bokeh is amazing

Are there any error messages reported in the browser's JavaScript console? My first guess would be that the CustomJS is executing but that the JS contained in it has some sort of syntax or other error.

Bryan

···

On Jan 3, 2017, at 8:30 AM, [email protected] wrote:

Even, I am facing exactly this issue. @Bryan, can you help us out here.

Thanks!

On Friday, 30 December 2016 13:19:20 UTC-5, PH wrote:
Hello,

I have been trying to generate a csv file as per the https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv
I have created a get_csv.js file as per the example and modified for my 2 columns Name, Quantity:

get_csv.js

var data = source_locate.data;
var filetext = 'Name,Quantity\n';
for (i=0; i < data['Name'].length; i++) {
    var currRow = [data['Name'][i].toString(),
                   data['Quantity'][i].toString()];

    var joined = currRow.join();
    filetext = filetext.concat(joined);
}

var filename = 'test.csv';
var blob = new Blob([filetext], { type: 'text/csv;charset=utf-8;' });

//addresses IE
if (navigator.msSaveBlob) {
    navigator.msSaveBlob(blob, filename);
}

else {
    var link = document.createElement("a");
    link = document.createElement('a')
    link.href = URL.createObjectURL(blob);
    link.download = filename
    link.target = "_blank";
    link.style.visibility = 'hidden';
    link.dispatchEvent(new MouseEvent('click'))
}

In main.py, I have :

source_locate = ColumnDataSource(data=dict(Name=,Quantity=))
source_locate.data = source.from_df( a python function that returns a dataframe)

button.callback = CustomJS(args=dict(source=source_locate),code = open(join(dirname(__file__), "get_csv.js")).read())

I do get this as on output from source_locate.data -->{'Name': ['A', 'B', 'C'], 'Quantity': [-14778600, -5471100, -52030900]}
so it seems to work but the CustomJS does not execute when I click on the button..

Thanks a lot for your help or for any feedbacks that can put me in the right direction...

Best and Happy new year to the all team.
Bokeh is amazing

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6e700e74-15c6-412b-a126-70cfc517c8b9%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Perhaps, it is not showing any error messages. I can click the button but the action cannot be completed meaning there is no download happening.

···

On Friday, 6 January 2017 14:57:04 UTC-5, Bryan Van de ven wrote:

Are there any error messages reported in the browser’s JavaScript console? My first guess would be that the CustomJS is executing but that the JS contained in it has some sort of syntax or other error.

Bryan

On Jan 3, 2017, at 8:30 AM, [email protected] wrote:

Even, I am facing exactly this issue. @Bryan, can you help us out here.

Thanks!

On Friday, 30 December 2016 13:19:20 UTC-5, PH wrote:

Hello,

I have been trying to generate a csv file as per the https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv

I have created a get_csv.js file as per the example and modified for my 2 columns Name, Quantity:

get_csv.js

var data = source_locate.data;

var filetext = ‘Name,Quantity\n’;

for (i=0; i < data[‘Name’].length; i++) {

var currRow = [data['Name'][i].toString(),
               data['Quantity'][i].toString()];
var joined = currRow.join();
filetext = filetext.concat(joined);

}

var filename = ‘test.csv’;

var blob = new Blob([filetext], { type: ‘text/csv;charset=utf-8;’ });

//addresses IE

if (navigator.msSaveBlob) {

navigator.msSaveBlob(blob, filename);

}

else {

var link = document.createElement("a");
link = document.createElement('a')
link.href = URL.createObjectURL(blob);
link.download = filename
link.target = "_blank";
link.style.visibility = 'hidden';
link.dispatchEvent(new MouseEvent('click'))

}

In main.py, I have :

source_locate = ColumnDataSource(data=dict(Name=,Quantity=))

source_locate.data = source.from_df( a python function that returns a dataframe)

button.callback = CustomJS(args=dict(source=source_locate),code = open(join(dirname(file), “get_csv.js”)).read())

I do get this as on output from source_locate.data -->{‘Name’: [‘A’, ‘B’, ‘C’], ‘Quantity’: [-14778600, -5471100, -52030900]}
so it seems to work but the CustomJS does not execute when I click on the button…

Thanks a lot for your help or for any feedbacks that can put me in the right direction…

Best and Happy new year to the all team.

Bokeh is amazing


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6e700e74-15c6-412b-a126-70cfc517c8b9%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Just for data points: does it work in other browsers or on other platforms?

Bryan

···

On Jan 6, 2017, at 2:01 PM, [email protected] wrote:

Perhaps, it is not showing any error messages. I can click the button but the action cannot be completed meaning there is no download happening.

On Friday, 6 January 2017 14:57:04 UTC-5, Bryan Van de ven wrote:
Are there any error messages reported in the browser's JavaScript console? My first guess would be that the CustomJS is executing but that the JS contained in it has some sort of syntax or other error.

Bryan

> On Jan 3, 2017, at 8:30 AM, pratik...@gmail.com wrote:
>
> Even, I am facing exactly this issue. @Bryan, can you help us out here.
>
> Thanks!
>
> On Friday, 30 December 2016 13:19:20 UTC-5, PH wrote:
> Hello,
>
> I have been trying to generate a csv file as per the https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv
> I have created a get_csv.js file as per the example and modified for my 2 columns Name, Quantity:
>
> get_csv.js
>
> var data = source_locate.data;
> var filetext = 'Name,Quantity\n';
> for (i=0; i < data['Name'].length; i++) {
> var currRow = [data['Name'][i].toString(),
> data['Quantity'][i].toString()];
>
> var joined = currRow.join();
> filetext = filetext.concat(joined);
> }
>
> var filename = 'test.csv';
> var blob = new Blob([filetext], { type: 'text/csv;charset=utf-8;' });
>
> //addresses IE
> if (navigator.msSaveBlob) {
> navigator.msSaveBlob(blob, filename);
> }
>
> else {
> var link = document.createElement("a");
> link = document.createElement('a')
> link.href = URL.createObjectURL(blob);
> link.download = filename
> link.target = "_blank";
> link.style.visibility = 'hidden';
> link.dispatchEvent(new MouseEvent('click'))
> }
>
> In main.py, I have :
>
> source_locate = ColumnDataSource(data=dict(Name=,Quantity=))
> source_locate.data = source.from_df( a python function that returns a dataframe)
>
> button.callback = CustomJS(args=dict(source=source_locate),code = open(join(dirname(__file__), "get_csv.js")).read())
>
> I do get this as on output from source_locate.data -->{'Name': ['A', 'B', 'C'], 'Quantity': [-14778600, -5471100, -52030900]}
> so it seems to work but the CustomJS does not execute when I click on the button..
>
> Thanks a lot for your help or for any feedbacks that can put me in the right direction...
>
> Best and Happy new year to the all team.
> Bokeh is amazing
>
>
>
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6e700e74-15c6-412b-a126-70cfc517c8b9%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/10c2e168-3264-49e3-96d4-b5c7fb634a24%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

I tried both in IE as well as Chrome. To that note: I did download the export_csv example from the demos and that ran successfully. I wonder if there is something we are missing. My code is similar to PH’s as above.

Thanks!

···

On Friday, 6 January 2017 15:14:21 UTC-5, Bryan Van de ven wrote:

Just for data points: does it work in other browsers or on other platforms?

Bryan

On Jan 6, 2017, at 2:01 PM, [email protected] wrote:

Perhaps, it is not showing any error messages. I can click the button but the action cannot be completed meaning there is no download happening.

On Friday, 6 January 2017 14:57:04 UTC-5, Bryan Van de ven wrote:

Are there any error messages reported in the browser’s JavaScript console? My first guess would be that the CustomJS is executing but that the JS contained in it has some sort of syntax or other error.

Bryan

On Jan 3, 2017, at 8:30 AM, [email protected] wrote:

Even, I am facing exactly this issue. @Bryan, can you help us out here.

Thanks!

On Friday, 30 December 2016 13:19:20 UTC-5, PH wrote:
Hello,

I have been trying to generate a csv file as per the https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv

I have created a get_csv.js file as per the example and modified for my 2 columns Name, Quantity:

get_csv.js

var data = source_locate.data;
var filetext = ‘Name,Quantity\n’;
for (i=0; i < data[‘Name’].length; i++) {
var currRow = [data[‘Name’][i].toString(),
data[‘Quantity’][i].toString()];

var joined = currRow.join();
filetext = filetext.concat(joined);

}

var filename = ‘test.csv’;
var blob = new Blob([filetext], { type: ‘text/csv;charset=utf-8;’ });

//addresses IE
if (navigator.msSaveBlob) {
navigator.msSaveBlob(blob, filename);
}

else {
var link = document.createElement(“a”);
link = document.createElement(‘a’)
link.href = URL.createObjectURL(blob);
link.download = filename
link.target = “_blank”;
link.style.visibility = ‘hidden’;
link.dispatchEvent(new MouseEvent(‘click’))
}

In main.py, I have :

source_locate = ColumnDataSource(data=dict(Name=,Quantity=))
source_locate.data = source.from_df( a python function that returns a dataframe)

button.callback = CustomJS(args=dict(source=source_locate),code = open(join(dirname(file), “get_csv.js”)).read())

I do get this as on output from source_locate.data -->{‘Name’: [‘A’, ‘B’, ‘C’], ‘Quantity’: [-14778600, -5471100, -52030900]}
so it seems to work but the CustomJS does not execute when I click on the button…

Thanks a lot for your help or for any feedbacks that can put me in the right direction…

Best and Happy new year to the all team.
Bokeh is amazing


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6e700e74-15c6-412b-a126-70cfc517c8b9%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/10c2e168-3264-49e3-96d4-b5c7fb634a24%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

I'm afraid I am not sure offhand, at this point I would suggest trying some old fashioned "print debugging". You can use the JS command

  console.log("stuff", obj.foo)

to print various things to the browsers JavaScript console. Some questions to try and answer:

* what are the lengths of the data columns?
* what is the value of data['Name'].length in particular
* is the contents of filetext correct/expected? (maybe use a small test data set)
* which branch of the "if" is being taken

Thanks,

Bryan

···

On Jan 6, 2017, at 2:16 PM, [email protected] wrote:

I tried both in IE as well as Chrome. To that note: I did download the export_csv example from the demos and that ran successfully. I wonder if there is something we are missing. My code is similar to PH's as above.

Thanks!

On Friday, 6 January 2017 15:14:21 UTC-5, Bryan Van de ven wrote:
Just for data points: does it work in other browsers or on other platforms?

Bryan

> On Jan 6, 2017, at 2:01 PM, pratik...@gmail.com wrote:
>
> Perhaps, it is not showing any error messages. I can click the button but the action cannot be completed meaning there is no download happening.
>
> On Friday, 6 January 2017 14:57:04 UTC-5, Bryan Van de ven wrote:
> Are there any error messages reported in the browser's JavaScript console? My first guess would be that the CustomJS is executing but that the JS contained in it has some sort of syntax or other error.
>
> Bryan
>
> > On Jan 3, 2017, at 8:30 AM, pratik...@gmail.com wrote:
> >
> > Even, I am facing exactly this issue. @Bryan, can you help us out here.
> >
> > Thanks!
> >
> > On Friday, 30 December 2016 13:19:20 UTC-5, PH wrote:
> > Hello,
> >
> > I have been trying to generate a csv file as per the https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv
> > I have created a get_csv.js file as per the example and modified for my 2 columns Name, Quantity:
> >
> > get_csv.js
> >
> > var data = source_locate.data;
> > var filetext = 'Name,Quantity\n';
> > for (i=0; i < data['Name'].length; i++) {
> > var currRow = [data['Name'][i].toString(),
> > data['Quantity'][i].toString()];
> >
> > var joined = currRow.join();
> > filetext = filetext.concat(joined);
> > }
> >
> > var filename = 'test.csv';
> > var blob = new Blob([filetext], { type: 'text/csv;charset=utf-8;' });
> >
> > //addresses IE
> > if (navigator.msSaveBlob) {
> > navigator.msSaveBlob(blob, filename);
> > }
> >
> > else {
> > var link = document.createElement("a");
> > link = document.createElement('a')
> > link.href = URL.createObjectURL(blob);
> > link.download = filename
> > link.target = "_blank";
> > link.style.visibility = 'hidden';
> > link.dispatchEvent(new MouseEvent('click'))
> > }
> >
> > In main.py, I have :
> >
> > source_locate = ColumnDataSource(data=dict(Name=,Quantity=))
> > source_locate.data = source.from_df( a python function that returns a dataframe)
> >
> > button.callback = CustomJS(args=dict(source=source_locate),code = open(join(dirname(__file__), "get_csv.js")).read())
> >
> > I do get this as on output from source_locate.data -->{'Name': ['A', 'B', 'C'], 'Quantity': [-14778600, -5471100, -52030900]}
> > so it seems to work but the CustomJS does not execute when I click on the button..
> >
> > Thanks a lot for your help or for any feedbacks that can put me in the right direction...
> >
> > Best and Happy new year to the all team.
> > Bokeh is amazing
> >
> >
> >
> >
> >
> >
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> > To post to this group, send email to bo...@continuum.io.
> > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6e700e74-15c6-412b-a126-70cfc517c8b9%40continuum.io\.
> > For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/10c2e168-3264-49e3-96d4-b5c7fb634a24%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/b4546f47-d02e-4d3b-9c08-2a2bd204ee05%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

  • The length of the data columns are probably around 250-300 rows

  • There are three different columns I am trying to print. One of them is Date and other two are purely numbers.

  • Haven’t tried with the small dataset - but I shall give it a try. Might be best bet at this point.

  • Didn’t really got this question

Thank you,

Pratik

···

On Friday, 6 January 2017 15:34:00 UTC-5, Bryan Van de ven wrote:

I’m afraid I am not sure offhand, at this point I would suggest trying some old fashioned “print debugging”. You can use the JS command

    console.log("stuff", obj.foo)

to print various things to the browsers JavaScript console. Some questions to try and answer:

  • what are the lengths of the data columns?

  • what is the value of data[‘Name’].length in particular

  • is the contents of filetext correct/expected? (maybe use a small test data set)

  • which branch of the “if” is being taken

Thanks,

Bryan

On Jan 6, 2017, at 2:16 PM, [email protected] wrote:

I tried both in IE as well as Chrome. To that note: I did download the export_csv example from the demos and that ran successfully. I wonder if there is something we are missing. My code is similar to PH’s as above.

Thanks!

On Friday, 6 January 2017 15:14:21 UTC-5, Bryan Van de ven wrote:

Just for data points: does it work in other browsers or on other platforms?

Bryan

On Jan 6, 2017, at 2:01 PM, [email protected] wrote:

Perhaps, it is not showing any error messages. I can click the button but the action cannot be completed meaning there is no download happening.

On Friday, 6 January 2017 14:57:04 UTC-5, Bryan Van de ven wrote:
Are there any error messages reported in the browser’s JavaScript console? My first guess would be that the CustomJS is executing but that the JS contained in it has some sort of syntax or other error.

Bryan

On Jan 3, 2017, at 8:30 AM, [email protected] wrote:

Even, I am facing exactly this issue. @Bryan, can you help us out here.

Thanks!

On Friday, 30 December 2016 13:19:20 UTC-5, PH wrote:
Hello,

I have been trying to generate a csv file as per the https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv

I have created a get_csv.js file as per the example and modified for my 2 columns Name, Quantity:

get_csv.js

var data = source_locate.data;
var filetext = ‘Name,Quantity\n’;
for (i=0; i < data[‘Name’].length; i++) {
var currRow = [data[‘Name’][i].toString(),
data[‘Quantity’][i].toString()];

var joined = currRow.join();
filetext = filetext.concat(joined);

}

var filename = ‘test.csv’;
var blob = new Blob([filetext], { type: ‘text/csv;charset=utf-8;’ });

//addresses IE
if (navigator.msSaveBlob) {
navigator.msSaveBlob(blob, filename);
}

else {
var link = document.createElement(“a”);
link = document.createElement(‘a’)
link.href = URL.createObjectURL(blob);
link.download = filename
link.target = “_blank”;
link.style.visibility = ‘hidden’;
link.dispatchEvent(new MouseEvent(‘click’))
}

In main.py, I have :

source_locate = ColumnDataSource(data=dict(Name=,Quantity=))
source_locate.data = source.from_df( a python function that returns a dataframe)

button.callback = CustomJS(args=dict(source=source_locate),code = open(join(dirname(file), “get_csv.js”)).read())

I do get this as on output from source_locate.data -->{‘Name’: [‘A’, ‘B’, ‘C’], ‘Quantity’: [-14778600, -5471100, -52030900]}
so it seems to work but the CustomJS does not execute when I click on the button…

Thanks a lot for your help or for any feedbacks that can put me in the right direction…

Best and Happy new year to the all team.
Bokeh is amazing


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6e700e74-15c6-412b-a126-70cfc517c8b9%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/10c2e168-3264-49e3-96d4-b5c7fb634a24%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/b4546f47-d02e-4d3b-9c08-2a2bd204ee05%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Sorry, I was not very clear. I was suggesting that you add console.log statements to the JS code to print things that would answer those questions exactly.

Bryan

···

On Jan 6, 2017, at 2:46 PM, [email protected] wrote:

  - The length of the data columns are probably around 250-300 rows
  - There are three different columns I am trying to print. One of them is Date and other two are purely numbers.
  - Haven't tried with the small dataset - but I shall give it a try. Might be best bet at this point.
  - Didn't really got this question

Thank you,
Pratik

On Friday, 6 January 2017 15:34:00 UTC-5, Bryan Van de ven wrote:
I'm afraid I am not sure offhand, at this point I would suggest trying some old fashioned "print debugging". You can use the JS command

        console.log("stuff", obj.foo)

to print various things to the browsers JavaScript console. Some questions to try and answer:

* what are the lengths of the data columns?
* what is the value of data['Name'].length in particular
* is the contents of filetext correct/expected? (maybe use a small test data set)
* which branch of the "if" is being taken

Thanks,

Bryan

> On Jan 6, 2017, at 2:16 PM, pratik...@gmail.com wrote:
>
> I tried both in IE as well as Chrome. To that note: I did download the export_csv example from the demos and that ran successfully. I wonder if there is something we are missing. My code is similar to PH's as above.
>
> Thanks!
>
> On Friday, 6 January 2017 15:14:21 UTC-5, Bryan Van de ven wrote:
> Just for data points: does it work in other browsers or on other platforms?
>
> Bryan
>
>
> > On Jan 6, 2017, at 2:01 PM, pratik...@gmail.com wrote:
> >
> > Perhaps, it is not showing any error messages. I can click the button but the action cannot be completed meaning there is no download happening.
> >
> > On Friday, 6 January 2017 14:57:04 UTC-5, Bryan Van de ven wrote:
> > Are there any error messages reported in the browser's JavaScript console? My first guess would be that the CustomJS is executing but that the JS contained in it has some sort of syntax or other error.
> >
> > Bryan
> >
> > > On Jan 3, 2017, at 8:30 AM, pratik...@gmail.com wrote:
> > >
> > > Even, I am facing exactly this issue. @Bryan, can you help us out here.
> > >
> > > Thanks!
> > >
> > > On Friday, 30 December 2016 13:19:20 UTC-5, PH wrote:
> > > Hello,
> > >
> > > I have been trying to generate a csv file as per the https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv
> > > I have created a get_csv.js file as per the example and modified for my 2 columns Name, Quantity:
> > >
> > > get_csv.js
> > >
> > > var data = source_locate.data;
> > > var filetext = 'Name,Quantity\n';
> > > for (i=0; i < data['Name'].length; i++) {
> > > var currRow = [data['Name'][i].toString(),
> > > data['Quantity'][i].toString()];
> > >
> > > var joined = currRow.join();
> > > filetext = filetext.concat(joined);
> > > }
> > >
> > > var filename = 'test.csv';
> > > var blob = new Blob([filetext], { type: 'text/csv;charset=utf-8;' });
> > >
> > > //addresses IE
> > > if (navigator.msSaveBlob) {
> > > navigator.msSaveBlob(blob, filename);
> > > }
> > >
> > > else {
> > > var link = document.createElement("a");
> > > link = document.createElement('a')
> > > link.href = URL.createObjectURL(blob);
> > > link.download = filename
> > > link.target = "_blank";
> > > link.style.visibility = 'hidden';
> > > link.dispatchEvent(new MouseEvent('click'))
> > > }
> > >
> > > In main.py, I have :
> > >
> > > source_locate = ColumnDataSource(data=dict(Name=,Quantity=))
> > > source_locate.data = source.from_df( a python function that returns a dataframe)
> > >
> > > button.callback = CustomJS(args=dict(source=source_locate),code = open(join(dirname(__file__), "get_csv.js")).read())
> > >
> > > I do get this as on output from source_locate.data -->{'Name': ['A', 'B', 'C'], 'Quantity': [-14778600, -5471100, -52030900]}
> > > so it seems to work but the CustomJS does not execute when I click on the button..
> > >
> > > Thanks a lot for your help or for any feedbacks that can put me in the right direction...
> > >
> > > Best and Happy new year to the all team.
> > > Bokeh is amazing
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > --
> > > You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> > > To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> > > To post to this group, send email to bo...@continuum.io.
> > > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6e700e74-15c6-412b-a126-70cfc517c8b9%40continuum.io\.
> > > For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
> >
> >
> > --
> > You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> > To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> > To post to this group, send email to bo...@continuum.io.
> > To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/10c2e168-3264-49e3-96d4-b5c7fb634a24%40continuum.io\.
> > For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
>
>
> --
> You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to bokeh+un...@continuum.io.
> To post to this group, send email to bo...@continuum.io.
> To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/b4546f47-d02e-4d3b-9c08-2a2bd204ee05%40continuum.io\.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

--
You received this message because you are subscribed to the Google Groups "Bokeh Discussion - Public" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/cf1de90f-8534-430e-b8cb-f40f363d5859%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Ahh. Okay let me try those.

Thanks Bryan!

Pratik

···

On Friday, 6 January 2017 15:54:55 UTC-5, Bryan Van de ven wrote:

Sorry, I was not very clear. I was suggesting that you add console.log statements to the JS code to print things that would answer those questions exactly.

Bryan

On Jan 6, 2017, at 2:46 PM, [email protected] wrote:

  • The length of the data columns are probably around 250-300 rows
  • There are three different columns I am trying to print. One of them is Date and other two are purely numbers.
  • Haven’t tried with the small dataset - but I shall give it a try. Might be best bet at this point.
  • Didn’t really got this question

Thank you,

Pratik

On Friday, 6 January 2017 15:34:00 UTC-5, Bryan Van de ven wrote:

I’m afraid I am not sure offhand, at this point I would suggest trying some old fashioned “print debugging”. You can use the JS command

    console.log("stuff", obj.foo)

to print various things to the browsers JavaScript console. Some questions to try and answer:

  • what are the lengths of the data columns?
  • what is the value of data[‘Name’].length in particular
  • is the contents of filetext correct/expected? (maybe use a small test data set)
  • which branch of the “if” is being taken

Thanks,

Bryan

On Jan 6, 2017, at 2:16 PM, [email protected] wrote:

I tried both in IE as well as Chrome. To that note: I did download the export_csv example from the demos and that ran successfully. I wonder if there is something we are missing. My code is similar to PH’s as above.

Thanks!

On Friday, 6 January 2017 15:14:21 UTC-5, Bryan Van de ven wrote:
Just for data points: does it work in other browsers or on other platforms?

Bryan

On Jan 6, 2017, at 2:01 PM, [email protected] wrote:

Perhaps, it is not showing any error messages. I can click the button but the action cannot be completed meaning there is no download happening.

On Friday, 6 January 2017 14:57:04 UTC-5, Bryan Van de ven wrote:
Are there any error messages reported in the browser’s JavaScript console? My first guess would be that the CustomJS is executing but that the JS contained in it has some sort of syntax or other error.

Bryan

On Jan 3, 2017, at 8:30 AM, [email protected] wrote:

Even, I am facing exactly this issue. @Bryan, can you help us out here.

Thanks!

On Friday, 30 December 2016 13:19:20 UTC-5, PH wrote:
Hello,

I have been trying to generate a csv file as per the https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv

I have created a get_csv.js file as per the example and modified for my 2 columns Name, Quantity:

get_csv.js

var data = source_locate.data;
var filetext = ‘Name,Quantity\n’;
for (i=0; i < data[‘Name’].length; i++) {
var currRow = [data[‘Name’][i].toString(),
data[‘Quantity’][i].toString()];

var joined = currRow.join();
filetext = filetext.concat(joined);

}

var filename = ‘test.csv’;
var blob = new Blob([filetext], { type: ‘text/csv;charset=utf-8;’ });

//addresses IE
if (navigator.msSaveBlob) {
navigator.msSaveBlob(blob, filename);
}

else {
var link = document.createElement(“a”);
link = document.createElement(‘a’)
link.href = URL.createObjectURL(blob);
link.download = filename
link.target = “_blank”;
link.style.visibility = ‘hidden’;
link.dispatchEvent(new MouseEvent(‘click’))
}

In main.py, I have :

source_locate = ColumnDataSource(data=dict(Name=,Quantity=))
source_locate.data = source.from_df( a python function that returns a dataframe)

button.callback = CustomJS(args=dict(source=source_locate),code = open(join(dirname(file), “get_csv.js”)).read())

I do get this as on output from source_locate.data -->{‘Name’: [‘A’, ‘B’, ‘C’], ‘Quantity’: [-14778600, -5471100, -52030900]}
so it seems to work but the CustomJS does not execute when I click on the button…

Thanks a lot for your help or for any feedbacks that can put me in the right direction…

Best and Happy new year to the all team.
Bokeh is amazing


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/6e700e74-15c6-412b-a126-70cfc517c8b9%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/10c2e168-3264-49e3-96d4-b5c7fb634a24%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/b4546f47-d02e-4d3b-9c08-2a2bd204ee05%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/cf1de90f-8534-430e-b8cb-f40f363d5859%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Here is another thread with a solution: Save plot data as csv