{"action":"created","comment":{"url":"https://api.github.com/repos/bendalab/NixView/pulls/comments/136702194","pull_request_review_id":60281080,"id":136702194,"diff_hunk":"@@ -76,41 +128,239 @@ void CSVExportDialog::export_csv() {\n     }\n     QTextStream outStream(&outfile);\n \n+    QString sep = ui->separator_edit->text().append(\" \");\n+\n+    if(array.dataExtent().size() == 1) {\n+        exportCsv1D(outStream, sep);\n+    } else if(array.dataExtent().size() == 2) {\n+        exportCsv2D(outStream, sep);\n+    } else if(array.dataExtent().size() == 3) {\n+        exportCsv3D(outStream, sep);\n+    } else if(array.dataExtent().size() > 3) {\n+        std::cerr << \"CSV-export of data with more than 3 dimensions currently not possible. Sorry!\" << std::endl;\n+    }\n+\n+    outfile.close();\n+    this->close();\n+}\n+\n+void CSVExportDialog::exportCsv1D(QTextStream &outStream, QString &sep) {\n+    QStringList vheader, hheader, dheader;\n     if (ui->export_header->isChecked()) {\n-        outStream << \" \" << sep << \" \";\n+        get_header(vheader, hheader, dheader);\n+    }\n+    nix::NDSize shape = array.dataExtent();\n+    nix::DataType type = array.dataType();\n+    nix::NDArray data = nix::NDArray(type, {1});\n+\n+    if (ui->export_header->isChecked()) {\n+        outStream << \" \" << sep;\n         for (int i = 0; i < hheader.size(); i++) {\n-            if (i >= min_col && i <= max_col) {\n-                outStream << hheader[i] << sep << \" \";\n-            }\n+            outStream << hheader[i] << sep;\n         }\n         outStream << \"\\n\";\n     }\n-    ui->progressBar->setValue(5);\n-    QCoreApplication::processEvents();\n-    double step = 95. / this->table->model()->rowCount();\n-    int count = 0;\n-    for (QModelIndex i: indexes) {\n-        QVariant var = table->model()->data(i);\n-        if (!var.canConvert<double>())\n-            continue;\n-        if (ui->export_header->isChecked()) {\n-            if (i.column() == min_col) {\n-                outStream << vheader[i.row()] << sep << \" \";\n-            }\n+\n+    if(! (ui->export_selection->isChecked()) || !testStartEnd()) {\n+        start[0] = 0;\n+        end[0] = shape[0];\n+    }\n+\n+    int count =0;\n+    int draw = 100;\n+    double step = 100. / (end[0]-start[0]);\n+\n+\n+\n+    for(int x = start[0]; x<(int)end[0]; x++) {\n+        if(ui->export_header->isChecked()) {\n+            outStream << vheader[x] << sep;\n         }\n-        if (i.column() < max_col) {\n-            outStream << var.value<double>() << sep << \" \";\n+\n+        array.getDataDirect(type, data.data(), {1}, {x});\n+        nix::NDSize index = nix::NDSize(1,0);\n+        //export depending on type:\n+        exportData(outStream, data, index, sep);\n+\n+        outStream << \"\\n\";\n+\n+        count++;\n+        if(count%draw == 0) {\n+            ui->progressBar->setValue(rint(count * step));\n+            QCoreApplication::processEvents();\n         }\n-        else {\n-            outStream << var.value<double>() << \"\\n\";\n+    }\n+}\n+\n+void CSVExportDialog::exportCsv2D(QTextStream &outStream, QString &sep) {\n+    QStringList vheader, hheader, dheader;\n+    if (ui->export_header->isChecked()) {\n+        get_header(vheader, hheader, dheader);\n+    }\n+    nix::NDSize shape = array.dataExtent();\n+    nix::DataType type = array.dataType();\n+\n+    if(! ui->export_selection->isChecked() || ! testStartEnd()) {\n+        start = nix::NDSize(2,0);\n+        end   = nix::NDSize(2, shape[0]);\n+        end[1] = shape[1];\n+    }\n+\n+    nix::NDArray data = nix::NDArray(type, {1, (int) (end[1]-start[1])});\n+\n+    int count =0;\n+    int draw = 100;\n+    double step = 100. / (end[0]-start[0]);\n+\n+    if(ui->export_header->isChecked()) {\n+        outStream << \" \" << sep;\n+        for (unsigned int i = start[1]; i < end[1]; i++) {\n+              outStream << hheader[i] << sep;\n         }\n-        ui->progressBar->setValue(5 + rint(count * step));\n-        QCoreApplication::processEvents();\n+        outStream << \"\\n\";\n+    }\n+\n+    for(int x = start[0]; x<(int)end[0]; x++) {\n+        if(ui->export_header->isChecked()) {\n+            outStream << vheader[x] << sep;\n+        }\n+        array.getDataDirect(type, data.data(), {1, (int) (end[1]-start[1])},   {x, (int)start[1]});\n+\n+        for(unsigned int y = 0; y<(end[1]-start[1]); y++) {\n+            nix::NDSize yIndex;\n+            yIndex = nix::NDSize(2,0);\n+            yIndex[1] = y;\n+            //export depending on type:\n+            exportData(outStream, data, yIndex, sep);\n+        }\n+        outStream << \"\\n\";\n+\n         count++;\n+        if(count%draw == 0) {\n+            ui->progressBar->setValue(rint(count * step));\n+            QCoreApplication::processEvents();\n+        }\n     }\n+}\n \n-    if (!ui->export_selection->isChecked())\n-        table->clearSelection();\n-    outfile.close();\n-    this->close();\n+void CSVExportDialog::exportCsv3D(QTextStream &outStream, QString &sep) {\n+    QStringList vheader, hheader, dheader;\n+    if (ui->export_header->isChecked()) {\n+        get_header(vheader, hheader, dheader);\n+    }\n+    nix::NDSize shape = array.dataExtent();\n+    nix::DataType type = array.dataType();\n+\n+    if( ! ui->export_selection->isChecked() || ! testStartEnd()) {\n+        start = nix::NDSize(3,0);","path":"dialogs/csvexportdialog.cpp","position":287,"original_position":287,"commit_id":"68d73a110ccf29400cc8be950f2afc096b014b53","original_commit_id":"68d73a110ccf29400cc8be950f2afc096b014b53","user":{"login":"jgrewe","id":772522,"avatar_url":"https://avatars2.githubusercontent.com/u/772522?v=4","gravatar_id":"","url":"https://api.github.com/users/jgrewe","html_url":"https://github.com/jgrewe","followers_url":"https://api.github.com/users/jgrewe/followers","following_url":"https://api.github.com/users/jgrewe/following{/other_user}","gists_url":"https://api.github.com/users/jgrewe/gists{/gist_id}","starred_url":"https://api.github.com/users/jgrewe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgrewe/subscriptions","organizations_url":"https://api.github.com/users/jgrewe/orgs","repos_url":"https://api.github.com/users/jgrewe/repos","events_url":"https://api.github.com/users/jgrewe/events{/privacy}","received_events_url":"https://api.github.com/users/jgrewe/received_events","type":"User","site_admin":false},"body":"not exactly related to this line, but the export selection makes no sense in the context of the direct export, via the menu...","created_at":"2017-09-02T19:22:04Z","updated_at":"2017-09-02T19:23:13Z","html_url":"https://github.com/bendalab/NixView/pull/91#discussion_r136702194","pull_request_url":"https://api.github.com/repos/bendalab/NixView/pulls/91","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/comments/136702194"},"html":{"href":"https://github.com/bendalab/NixView/pull/91#discussion_r136702194"},"pull_request":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/91"}}},"pull_request":{"url":"https://api.github.com/repos/bendalab/NixView/pulls/91","id":138886727,"html_url":"https://github.com/bendalab/NixView/pull/91","diff_url":"https://github.com/bendalab/NixView/pull/91.diff","patch_url":"https://github.com/bendalab/NixView/pull/91.patch","issue_url":"https://api.github.com/repos/bendalab/NixView/issues/91","number":91,"state":"open","locked":false,"title":"Change of csv export.","user":{"login":"Nyxas","id":30521779,"avatar_url":"https://avatars3.githubusercontent.com/u/30521779?v=4","gravatar_id":"","url":"https://api.github.com/users/Nyxas","html_url":"https://github.com/Nyxas","followers_url":"https://api.github.com/users/Nyxas/followers","following_url":"https://api.github.com/users/Nyxas/following{/other_user}","gists_url":"https://api.github.com/users/Nyxas/gists{/gist_id}","starred_url":"https://api.github.com/users/Nyxas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nyxas/subscriptions","organizations_url":"https://api.github.com/users/Nyxas/orgs","repos_url":"https://api.github.com/users/Nyxas/repos","events_url":"https://api.github.com/users/Nyxas/events{/privacy}","received_events_url":"https://api.github.com/users/Nyxas/received_events","type":"User","site_admin":false},"body":"In this PR:\r\n- added a menu option export with the csv export.\r\n- changed the csv export to work on basis of the NDArray instead of QTableview.\r\n- added support for the export of 3d data.\r\n- changed the way the selection based export works to fit with the switch to NDArray\r\n ","created_at":"2017-09-01T13:07:31Z","updated_at":"2017-09-02T19:23:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e77ce909710f4236ef68979ac0cc029e3ed338c5","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/bendalab/NixView/pulls/91/commits","review_comments_url":"https://api.github.com/repos/bendalab/NixView/pulls/91/comments","review_comment_url":"https://api.github.com/repos/bendalab/NixView/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bendalab/NixView/issues/91/comments","statuses_url":"https://api.github.com/repos/bendalab/NixView/statuses/68d73a110ccf29400cc8be950f2afc096b014b53","head":{"label":"Nyxas:feature","ref":"feature","sha":"68d73a110ccf29400cc8be950f2afc096b014b53","user":{"login":"Nyxas","id":30521779,"avatar_url":"https://avatars3.githubusercontent.com/u/30521779?v=4","gravatar_id":"","url":"https://api.github.com/users/Nyxas","html_url":"https://github.com/Nyxas","followers_url":"https://api.github.com/users/Nyxas/followers","following_url":"https://api.github.com/users/Nyxas/following{/other_user}","gists_url":"https://api.github.com/users/Nyxas/gists{/gist_id}","starred_url":"https://api.github.com/users/Nyxas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nyxas/subscriptions","organizations_url":"https://api.github.com/users/Nyxas/orgs","repos_url":"https://api.github.com/users/Nyxas/repos","events_url":"https://api.github.com/users/Nyxas/events{/privacy}","received_events_url":"https://api.github.com/users/Nyxas/received_events","type":"User","site_admin":false},"repo":{"id":98636828,"name":"NixView","full_name":"Nyxas/NixView","owner":{"login":"Nyxas","id":30521779,"avatar_url":"https://avatars3.githubusercontent.com/u/30521779?v=4","gravatar_id":"","url":"https://api.github.com/users/Nyxas","html_url":"https://github.com/Nyxas","followers_url":"https://api.github.com/users/Nyxas/followers","following_url":"https://api.github.com/users/Nyxas/following{/other_user}","gists_url":"https://api.github.com/users/Nyxas/gists{/gist_id}","starred_url":"https://api.github.com/users/Nyxas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Nyxas/subscriptions","organizations_url":"https://api.github.com/users/Nyxas/orgs","repos_url":"https://api.github.com/users/Nyxas/repos","events_url":"https://api.github.com/users/Nyxas/events{/privacy}","received_events_url":"https://api.github.com/users/Nyxas/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Nyxas/NixView","description":"Viewer for nix datafiles","fork":true,"url":"https://api.github.com/repos/Nyxas/NixView","forks_url":"https://api.github.com/repos/Nyxas/NixView/forks","keys_url":"https://api.github.com/repos/Nyxas/NixView/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Nyxas/NixView/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Nyxas/NixView/teams","hooks_url":"https://api.github.com/repos/Nyxas/NixView/hooks","issue_events_url":"https://api.github.com/repos/Nyxas/NixView/issues/events{/number}","events_url":"https://api.github.com/repos/Nyxas/NixView/events","assignees_url":"https://api.github.com/repos/Nyxas/NixView/assignees{/user}","branches_url":"https://api.github.com/repos/Nyxas/NixView/branches{/branch}","tags_url":"https://api.github.com/repos/Nyxas/NixView/tags","blobs_url":"https://api.github.com/repos/Nyxas/NixView/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Nyxas/NixView/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Nyxas/NixView/git/refs{/sha}","trees_url":"https://api.github.com/repos/Nyxas/NixView/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Nyxas/NixView/statuses/{sha}","languages_url":"https://api.github.com/repos/Nyxas/NixView/languages","stargazers_url":"https://api.github.com/repos/Nyxas/NixView/stargazers","contributors_url":"https://api.github.com/repos/Nyxas/NixView/contributors","subscribers_url":"https://api.github.com/repos/Nyxas/NixView/subscribers","subscription_url":"https://api.github.com/repos/Nyxas/NixView/subscription","commits_url":"https://api.github.com/repos/Nyxas/NixView/commits{/sha}","git_commits_url":"https://api.github.com/repos/Nyxas/NixView/git/commits{/sha}","comments_url":"https://api.github.com/repos/Nyxas/NixView/comments{/number}","issue_comment_url":"https://api.github.com/repos/Nyxas/NixView/issues/comments{/number}","contents_url":"https://api.github.com/repos/Nyxas/NixView/contents/{+path}","compare_url":"https://api.github.com/repos/Nyxas/NixView/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Nyxas/NixView/merges","archive_url":"https://api.github.com/repos/Nyxas/NixView/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Nyxas/NixView/downloads","issues_url":"https://api.github.com/repos/Nyxas/NixView/issues{/number}","pulls_url":"https://api.github.com/repos/Nyxas/NixView/pulls{/number}","milestones_url":"https://api.github.com/repos/Nyxas/NixView/milestones{/number}","notifications_url":"https://api.github.com/repos/Nyxas/NixView/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Nyxas/NixView/labels{/name}","releases_url":"https://api.github.com/repos/Nyxas/NixView/releases{/id}","deployments_url":"https://api.github.com/repos/Nyxas/NixView/deployments","created_at":"2017-07-28T10:03:05Z","updated_at":"2017-07-28T10:03:07Z","pushed_at":"2017-09-01T12:44:32Z","git_url":"git://github.com/Nyxas/NixView.git","ssh_url":"git@github.com:Nyxas/NixView.git","clone_url":"https://github.com/Nyxas/NixView.git","svn_url":"https://github.com/Nyxas/NixView","homepage":"http://bendalab.github.io/NixView","size":10738,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bendalab:master","ref":"master","sha":"99a3dc50b0261efdcc6f007b14f6ea4b836fac92","user":{"login":"bendalab","id":10567758,"avatar_url":"https://avatars0.githubusercontent.com/u/10567758?v=4","gravatar_id":"","url":"https://api.github.com/users/bendalab","html_url":"https://github.com/bendalab","followers_url":"https://api.github.com/users/bendalab/followers","following_url":"https://api.github.com/users/bendalab/following{/other_user}","gists_url":"https://api.github.com/users/bendalab/gists{/gist_id}","starred_url":"https://api.github.com/users/bendalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendalab/subscriptions","organizations_url":"https://api.github.com/users/bendalab/orgs","repos_url":"https://api.github.com/users/bendalab/repos","events_url":"https://api.github.com/users/bendalab/events{/privacy}","received_events_url":"https://api.github.com/users/bendalab/received_events","type":"Organization","site_admin":false},"repo":{"id":41813337,"name":"NixView","full_name":"bendalab/NixView","owner":{"login":"bendalab","id":10567758,"avatar_url":"https://avatars0.githubusercontent.com/u/10567758?v=4","gravatar_id":"","url":"https://api.github.com/users/bendalab","html_url":"https://github.com/bendalab","followers_url":"https://api.github.com/users/bendalab/followers","following_url":"https://api.github.com/users/bendalab/following{/other_user}","gists_url":"https://api.github.com/users/bendalab/gists{/gist_id}","starred_url":"https://api.github.com/users/bendalab/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bendalab/subscriptions","organizations_url":"https://api.github.com/users/bendalab/orgs","repos_url":"https://api.github.com/users/bendalab/repos","events_url":"https://api.github.com/users/bendalab/events{/privacy}","received_events_url":"https://api.github.com/users/bendalab/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bendalab/NixView","description":"Viewer for nix datafiles","fork":false,"url":"https://api.github.com/repos/bendalab/NixView","forks_url":"https://api.github.com/repos/bendalab/NixView/forks","keys_url":"https://api.github.com/repos/bendalab/NixView/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bendalab/NixView/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bendalab/NixView/teams","hooks_url":"https://api.github.com/repos/bendalab/NixView/hooks","issue_events_url":"https://api.github.com/repos/bendalab/NixView/issues/events{/number}","events_url":"https://api.github.com/repos/bendalab/NixView/events","assignees_url":"https://api.github.com/repos/bendalab/NixView/assignees{/user}","branches_url":"https://api.github.com/repos/bendalab/NixView/branches{/branch}","tags_url":"https://api.github.com/repos/bendalab/NixView/tags","blobs_url":"https://api.github.com/repos/bendalab/NixView/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bendalab/NixView/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bendalab/NixView/git/refs{/sha}","trees_url":"https://api.github.com/repos/bendalab/NixView/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bendalab/NixView/statuses/{sha}","languages_url":"https://api.github.com/repos/bendalab/NixView/languages","stargazers_url":"https://api.github.com/repos/bendalab/NixView/stargazers","contributors_url":"https://api.github.com/repos/bendalab/NixView/contributors","subscribers_url":"https://api.github.com/repos/bendalab/NixView/subscribers","subscription_url":"https://api.github.com/repos/bendalab/NixView/subscription","commits_url":"https://api.github.com/repos/bendalab/NixView/commits{/sha}","git_commits_url":"https://api.github.com/repos/bendalab/NixView/git/commits{/sha}","comments_url":"https://api.github.com/repos/bendalab/NixView/comments{/number}","issue_comment_url":"https://api.github.com/repos/bendalab/NixView/issues/comments{/number}","contents_url":"https://api.github.com/repos/bendalab/NixView/contents/{+path}","compare_url":"https://api.github.com/repos/bendalab/NixView/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bendalab/NixView/merges","archive_url":"https://api.github.com/repos/bendalab/NixView/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bendalab/NixView/downloads","issues_url":"https://api.github.com/repos/bendalab/NixView/issues{/number}","pulls_url":"https://api.github.com/repos/bendalab/NixView/pulls{/number}","milestones_url":"https://api.github.com/repos/bendalab/NixView/milestones{/number}","notifications_url":"https://api.github.com/repos/bendalab/NixView/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bendalab/NixView/labels{/name}","releases_url":"https://api.github.com/repos/bendalab/NixView/releases{/id}","deployments_url":"https://api.github.com/repos/bendalab/NixView/deployments","created_at":"2015-09-02T16:39:48Z","updated_at":"2017-04-09T03:18:49Z","pushed_at":"2017-09-01T13:07:33Z","git_url":"git://github.com/bendalab/NixView.git","ssh_url":"git@github.com:bendalab/NixView.git","clone_url":"https://github.com/bendalab/NixView.git","svn_url":"https://github.com/bendalab/NixView","homepage":"http://bendalab.github.io/NixView","size":10722,"stargazers_count":5,"watchers_count":5,"language":"C++","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":6,"mirror_url":null,"open_issues_count":11,"forks":6,"open_issues":11,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/91"},"html":{"href":"https://github.com/bendalab/NixView/pull/91"},"issue":{"href":"https://api.github.com/repos/bendalab/NixView/issues/91"},"comments":{"href":"https://api.github.com/repos/bendalab/NixView/issues/91/comments"},"review_comments":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/91/comments"},"review_comment":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bendalab/NixView/pulls/91/commits"},"statuses":{"href":"https://api.github.com/repos/bendalab/NixView/statuses/68d73a110ccf29400cc8be950f2afc096b014b53"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"jgrewe"}}