Angular TypeScript - Разбор файла CSV - PullRequest
0 голосов
/ 27 декабря 2018

Я пытаюсь проанализировать файл CSV с помощью пакета convert-csv-to-json.Вот мой код компонента:

import { Component, OnInit } from '@angular/core';
import csvToJson from 'convert-csv-to-json';


@Component({
  selector: 'app-csv-reader',
  templateUrl: './csv-reader.component.html',
  styleUrls: ['./csv-reader.component.css']
})
export class CsvReaderComponent implements OnInit {
    private fileInputName:any = 'csv-files/month_year_conversion.csv'; 
    private fileOutputName:any = 'myOutputFile.json';

    constructor() { 

    }

    private loadCsv(){
        return new Promise((resolve)=> {
            csvToJson.generateJsonFileFromCsv(this.fileInputName, this.fileOutputName);
            resolve();
        });
    }
    ngOnInit() {
        this.loadCsv();
    }

}

Но у меня есть следующая ошибка:

ОШИБКА в ./node_modules/convert-csv-to-json/src/util/fileUtils.js Модуль не найден: Ошибка: не удается разрешить 'fs' в 'C: \ Users \ m269552 \ Documents \ Node \ Tracules \ convert-csv-to-json \ src \ util'

Не могли бы вы помочь или дать показания, пожалуйста?

Спасибо.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...