-
Notifications
You must be signed in to change notification settings - Fork 2.8k
[ZEPPELIN-997] Export data to csv #1008
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,11 +41,21 @@ | |
| ng-click="setGraphMode('scatterChart', true)"><i class="cf cf-scatter-chart"></i> | ||
| </button> | ||
| </div> | ||
| <span> | ||
| <button type="button" class="btn btn-default btn-sm" style="margin-left:10px" | ||
| tooltip="Download Data as TSV" tooltip-placement="bottom" | ||
| ng-click="exportToTSV()"><i class="fa fa-download"></i> | ||
| <span class="btn-group"> | ||
| <button type="button" class="btn btn-default btn-sm" | ||
| style="margin-left:10px" | ||
| ng-click="exportToDSV(',')"> | ||
| <i class="fa fa-download"></i> | ||
| </button> | ||
| <button type="button" class="btn btn-default btn-sm dropdown-toggle" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| data-toggle="dropdown"> | ||
| <span class="caret" style="margin: 0px;"></span> | ||
| <span class="sr-only">Toggle Dropdown</span> | ||
| </button> | ||
| <ul class="dropdown-menu" role="menu" style="min-width: 70px;"> | ||
| <li ng-click="exportToDSV(',')"><a>CSV</a></li> | ||
| <li ng-click="exportToDSV('\t')"><a>TSV</a></li> | ||
| </ul> | ||
| </span> | ||
| <span ng-if="getGraphMode()!='table'" | ||
| style="margin-left:5px; cursor:pointer; display: inline-block; vertical-align:top; position: relative; line-height:30px;"> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2145,21 +2145,27 @@ angular.module('zeppelinWebApp') | |
| $scope.keepScrollDown = false; | ||
| }; | ||
|
|
||
| $scope.exportToTSV = function () { | ||
| $scope.exportToDSV = function (delimiter) { | ||
| var data = $scope.paragraph.result; | ||
| var tsv = ''; | ||
| var dsv = ''; | ||
| for (var titleIndex in $scope.paragraph.result.columnNames) { | ||
| tsv += $scope.paragraph.result.columnNames[titleIndex].name + '\t'; | ||
| dsv += $scope.paragraph.result.columnNames[titleIndex].name + delimiter; | ||
| } | ||
| tsv = tsv.substring(0, tsv.length - 1) + '\n'; | ||
| dsv = dsv.substring(0, dsv.length - 1) + '\n'; | ||
| for (var r in $scope.paragraph.result.msgTable) { | ||
| var row = $scope.paragraph.result.msgTable[r]; | ||
| var tsvRow = ''; | ||
| var dsvRow = ''; | ||
| for (var index in row) { | ||
| tsvRow += row[index].value + '\t'; | ||
| dsvRow += row[index].value + delimiter; | ||
| } | ||
| tsv += tsvRow.substring(0, tsvRow.length - 1) + '\n'; | ||
| dsv += dsvRow.substring(0, dsvRow.length - 1) + '\n'; | ||
| } | ||
| SaveAsService.SaveAs(tsv, 'data', 'tsv'); | ||
| var extension = ''; | ||
| if (delimiter === '\t') { | ||
| extension = 'tsv'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is likely out of scope for this change, for csv (likely tsv), strictly speaking we would need to escape any |
||
| } else if (delimiter === ',') { | ||
| extension = 'csv'; | ||
| } | ||
| SaveAsService.SaveAs(dsv, 'data', extension); | ||
| }; | ||
| }); | ||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you restore the tooltip on the main button? (with CSV instead of TSV)