I am new to angular-4 and I want to read a csv file from angular-4 assets directory, file size 5mb and I dont\'t want to read this file from django back-end server because this
In case you use the new HttpClient class (@angular/common/http), then you will have to set the responseType to 'text', otherwise the HttpClient class would try to interpret the content as json and raise a SyntaxError...
e.g.:
this.http.get('assets/file.csv', {responseType: 'text'})
.subscribe(
data => {
console.log(data);
},
error => {
console.log(error);
}
);
I finally find a answer Here is how I done it:
csvUrl = 'assets/demo-Results.csv';
readCsvData () {
this.http.get(this.csvUrl)
.subscribe(
data => {
console.log(data.text())
},
err => {
console.log(err)
});
}