Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface EvaluateHistoryItem {
- evaluate: string;
- error?: string;
- result?: string;
- runTimeMs?: number;
- saved?: boolean;
- }
- export class EvaluateComponent implements OnInit, AfterViewInit {
- ... ... ...
- ... ... ...
- public history$ = new BehaviorSubject<EvaluateHistoryItem[]>([]);
- ... ... ...
- public uploadFile(element: any) {
- let uploadedFile = document.getElementById('uploadedFile');
- let files: File[] = element.srcElement.files;
- let file: File = files[0];
- let reader = new FileReader();
- let resultSet: string[] = [];
- reader.onloadend = (result) => {
- // replace new lines with commas and then split upon commas but not the ones inside quotes
- let columns: string[] = reader.result.replace(/n/g, ',').split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);
- for (let i = 0; i < columns.length - 1; i++) {
- resultSet.push(columns[i]);
- }
- };
- let history: EvaluateHistoryItem[] = this.history$.getValue();
- // ... here I need to map values from resultSet
- // ....
- this.history$.next(history);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement