You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zeppelin.apache.org by co...@apache.org on 2016/06/08 06:41:14 UTC

incubator-zeppelin git commit: Exporting to TSV

Repository: incubator-zeppelin
Updated Branches:
  refs/heads/master 901102a72 -> 6994319a8


Exporting to TSV

### What is this PR for?
Allow users to export data in a paragraph to a TSV file.

There is already a [PR](https://github.com/apache/incubator-zeppelin/pull/6) for this, but it uses DataTables, which requires Flash.

### What type of PR is it?
Feature

### Todos
* [ ] - Hide/disable the button if it is not in table/chart view
* [ ] - Find an icon for the new button
* [ ] - Saved file name is not correct in Safari
* [ ] - Test with large data set

### Is there a relevant Jira issue?
[ZEPPELIN-672](https://issues.apache.org/jira/browse/ZEPPELIN-672)

### How should this be tested?
1. create a paragraph with data in %table view
2. select the "Export to TSV" item in the paragraph settings list

### Screenshots (if appropriate)
![vvzhsyciev](https://cloud.githubusercontent.com/assets/3282033/13032147/d589e88e-d29c-11e5-8763-96fca4db2fd0.gif)

### Questions:
* Does the licenses files need update?
NO

* Is there breaking changes for older versions?
NO

* Does this needs documentation?
NO

Author: Zhong Wang <wa...@gmail.com>

Closes #714 from zhongneu/export-to-tsv and squashes the following commits:

3c9e9e6 [Zhong Wang] fix missing semicolons
089018e [Zhong Wang] first attempt to implement exporting to TSV


Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/6994319a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/6994319a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/6994319a

Branch: refs/heads/master
Commit: 6994319a8b209b1b5afbf24b81f517a47e3d86eb
Parents: 901102a
Author: Zhong Wang <wa...@gmail.com>
Authored: Sat Feb 13 22:07:59 2016 -0800
Committer: Damien CORNEAU <co...@gmail.com>
Committed: Wed Jun 8 15:40:50 2016 +0900

----------------------------------------------------------------------
 .../notebook/paragraph/paragraph-control.html    |  3 +++
 .../notebook/paragraph/paragraph.controller.js   | 19 ++++++++++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/6994319a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html b/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html
index c35c4e5..7c51f3a 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph-control.html
@@ -83,6 +83,9 @@ limitations under the License.
         <a ng-click="goToSingleParagraph()"><span class="icon-share-alt"></span> Link this paragraph</a>
       </li>
       <li>
+        <a ng-click="exportToTSV()"><span class="icon-share-alt"></span> Export to TSV</a>
+      </li>
+      <li>
         <a ng-click="clearParagraphOutput()"><span class="fa fa-eraser"></span> Clear output</a>
       </li>
       <li>

http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/6994319a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
----------------------------------------------------------------------
diff --git a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
index 3c86737..c819565 100644
--- a/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
+++ b/zeppelin-web/src/app/notebook/paragraph/paragraph.controller.js
@@ -16,7 +16,7 @@
 
 angular.module('zeppelinWebApp')
   .controller('ParagraphCtrl', function($scope,$rootScope, $route, $window, $element, $routeParams, $location,
-                                         $timeout, $compile, websocketMsgSrv, ngToast) {
+                                         $timeout, $compile, websocketMsgSrv, ngToast, SaveAsService) {
   var ANGULAR_FUNCTION_OBJECT_NAME_PREFIX = '_Z_ANGULAR_FUNC_';
   $scope.parentNote = null;
   $scope.paragraph = null;
@@ -2143,4 +2143,21 @@ angular.module('zeppelinWebApp')
     $scope.keepScrollDown = false;
   };
 
+  $scope.exportToTSV = function () {
+    var data = $scope.paragraph.result;
+    var tsv = '';
+    for (var titleIndex in $scope.paragraph.result.columnNames) {
+      tsv += $scope.paragraph.result.columnNames[titleIndex].name + '\t';
+    }
+    tsv = tsv.substring(0, tsv.length - 1) + '\n';
+    for (var r in $scope.paragraph.result.msgTable) {
+      var row = $scope.paragraph.result.msgTable[r];
+      var tsvRow = '';
+      for (var index in row) {
+        tsvRow += row[index].value + '\t';
+      }
+      tsv += tsvRow.substring(0, tsvRow.length - 1) + '\n';
+    }
+    SaveAsService.SaveAs(tsv, 'data', 'tsv');
+  };
 });