Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. interface EvaluateHistoryItem {
  2. evaluate: string;
  3. error?: string;
  4. result?: string;
  5. runTimeMs?: number;
  6. saved?: boolean;
  7. }
  8.  
  9. export class EvaluateComponent implements OnInit, AfterViewInit {
  10. ... ... ...
  11. ... ... ...
  12. public history$ = new BehaviorSubject<EvaluateHistoryItem[]>([]);
  13. ... ... ...
  14. public uploadFile(element: any) {
  15. let uploadedFile = document.getElementById('uploadedFile');
  16. let files: File[] = element.srcElement.files;
  17. let file: File = files[0];
  18.  
  19. let reader = new FileReader();
  20.  
  21. let resultSet: string[] = [];
  22.  
  23. reader.onloadend = (result) => {
  24. // replace new lines with commas and then split upon commas but not the ones inside quotes
  25. let columns: string[] = reader.result.replace(/n/g, ',').split(/,(?=(?:(?:[^"]*"){2})*[^"]*$)/);
  26.  
  27. for (let i = 0; i < columns.length - 1; i++) {
  28. resultSet.push(columns[i]);
  29. }
  30. };
  31.  
  32. let history: EvaluateHistoryItem[] = this.history$.getValue();
  33. // ... here I need to map values from resultSet
  34. // ....
  35. this.history$.next(history);
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement