Add CSV prediction export
This commit is contained in:
parent
b54e167ee7
commit
4c88db301f
17
package-lock.json
generated
17
package-lock.json
generated
@ -2034,6 +2034,12 @@
|
|||||||
"integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==",
|
"integrity": "sha512-EaObqwIvayI5a8dCzhFrjKzVwKLxjoG9T6Ppd5CEo07LRKfQ8Yokw54r5+Wq7FaBQ+yXRvQAYPrHwya1/UFt9g==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"@types/file-saver": {
|
||||||
|
"version": "2.0.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/file-saver/-/file-saver-2.0.1.tgz",
|
||||||
|
"integrity": "sha512-g1QUuhYVVAamfCifK7oB7G3aIl4BbOyzDOqVyUfEr4tfBKrXfeH+M+Tg7HKCXSrbzxYdhyCP7z9WbKo0R2hBCw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"@types/glob": {
|
"@types/glob": {
|
||||||
"version": "7.1.1",
|
"version": "7.1.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/glob/-/glob-7.1.1.tgz",
|
||||||
@ -2067,9 +2073,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "12.12.41",
|
"version": "12.19.9",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.41.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.19.9.tgz",
|
||||||
"integrity": "sha512-Q+eSkdYQJ2XK1AJnr4Ji8Gvk3sRDybEwfTvtL9CA25FFUSD2EgZQewN6VCyWYZCXg5MWZdwogdTNBhlWRcWS1w==",
|
"integrity": "sha512-yj0DOaQeUrk3nJ0bd3Y5PeDRJ6W0r+kilosLA+dzF3dola/o9hxhMSg2sFvVcA2UHS5JSOsZp4S0c1OEXc4m1Q==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/q": {
|
"@types/q": {
|
||||||
@ -5515,6 +5521,11 @@
|
|||||||
"schema-utils": "^2.6.5"
|
"schema-utils": "^2.6.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"file-saver": {
|
||||||
|
"version": "2.0.5",
|
||||||
|
"resolved": "https://registry.npmjs.org/file-saver/-/file-saver-2.0.5.tgz",
|
||||||
|
"integrity": "sha512-P9bmyZ3h/PRG+Nzga+rbdI4OEpNDzAVyy74uVO9ATgzLK6VtAsYybF/+TOCvrc0MO793d6+42lLyZTw7/ArVzA=="
|
||||||
|
},
|
||||||
"file-uri-to-path": {
|
"file-uri-to-path": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
"angular-2-local-storage": "^3.0.2",
|
"angular-2-local-storage": "^3.0.2",
|
||||||
"chart.js": "^2.9.3",
|
"chart.js": "^2.9.3",
|
||||||
"chartjs-plugin-datalabels": "^0.7.0",
|
"chartjs-plugin-datalabels": "^0.7.0",
|
||||||
|
"file-saver": "^2.0.5",
|
||||||
"flatpickr": "^4.6.3",
|
"flatpickr": "^4.6.3",
|
||||||
"lodash": "^4.17.15",
|
"lodash": "^4.17.15",
|
||||||
"ng2-charts": "^2.3.2",
|
"ng2-charts": "^2.3.2",
|
||||||
@ -42,9 +43,9 @@
|
|||||||
"@angular/cli": "~9.1.6",
|
"@angular/cli": "~9.1.6",
|
||||||
"@angular/compiler-cli": "~9.1.7",
|
"@angular/compiler-cli": "~9.1.7",
|
||||||
"@angular/language-service": "~9.1.7",
|
"@angular/language-service": "~9.1.7",
|
||||||
|
"@types/file-saver": "^2.0.1",
|
||||||
"@types/jasmine": "~3.3.8",
|
"@types/jasmine": "~3.3.8",
|
||||||
"@types/jasminewd2": "~2.0.3",
|
"@types/jasminewd2": "~2.0.3",
|
||||||
"@types/node": "^12.11.1",
|
|
||||||
"codelyzer": "^5.1.2",
|
"codelyzer": "^5.1.2",
|
||||||
"jasmine-core": "~3.4.0",
|
"jasmine-core": "~3.4.0",
|
||||||
"jasmine-spec-reporter": "~4.2.1",
|
"jasmine-spec-reporter": "~4.2.1",
|
||||||
|
@ -60,6 +60,10 @@
|
|||||||
<rb-form-radio name="multiple-samples" label="Multiple samples" [(ngModel)]="multipleSamples" [value]="true">
|
<rb-form-radio name="multiple-samples" label="Multiple samples" [(ngModel)]="multipleSamples" [value]="true">
|
||||||
</rb-form-radio>
|
</rb-form-radio>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<rb-icon-button icon="forward-right" mode="primary" (click)="exportCSV()" *ngIf="spectrumNames.length">
|
||||||
|
Export to CSV
|
||||||
|
</rb-icon-button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="dpt-chart space-below">
|
<div class="dpt-chart space-below">
|
||||||
|
@ -6,6 +6,7 @@ import cloneDeep from 'lodash/cloneDeep';
|
|||||||
import omit from 'lodash/omit';
|
import omit from 'lodash/omit';
|
||||||
import { DataService } from '../services/data.service';
|
import { DataService } from '../services/data.service';
|
||||||
import { ModelItemModel } from '../models/model-item.model';
|
import { ModelItemModel } from '../models/model-item.model';
|
||||||
|
import * as FileSaver from 'file-saver'
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -121,7 +122,10 @@ export class PredictionComponent implements OnInit {
|
|||||||
this.result = undefined;
|
this.result = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
clip(str) { // clip spaces at start and end
|
exportCSV() {
|
||||||
return str.replace(/^\s*(.*?)\s*$/, '$1');
|
const zip = (a, b) => a.map((k, i) => [k, b[i]]);
|
||||||
|
const predictions = zip(this.spectrumNames, this.result.predictions.map(p => p[0].value));
|
||||||
|
const csv = predictions.map(line => line.join(";")).join("\n");
|
||||||
|
FileSaver.saveAs(new Blob([csv], { type: 'text/csv;charset=utf-8' }), "predictions.csv");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user