Include CSV file in build


#1

Hey there, I’m building my first Ionic app and I’m using a CSV file as the data source for a table.
How can I include this file on a release build?


#2

Include the file in your assets folder, for example:

├── /assets
    └── /data
        ├── data-file.csv

Get whole data from Firebase and save it in Assets folder as a .json
#3

Hey, thanks in advance!
It seems that it is included, judging by the increase in APK’s size but I can’t seem to find my file

I’ve tried using the File plugin on “applicationDirectory”


#4

Things in assets are not files from the POV of the device. They are baked into your app binary. HTTP is the simplest way to retrieve them.


#5

Try something like:

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { Observable } from 'rxjs/Observable';

import { Venue } from '@core/models';

@Injectable()
export class MockVenuesService  {

  private readonly URL = 'assets/data/venues.json';

  constructor(protected httpClient: HttpClient) {}

  public list(): Observable<Venue[]>   {
    return this.httpClient.get<Venue[]>(this.URL);
  }

}

See:


Get whole data from Firebase and save it in Assets folder as a .json
#6

hey sorry for the huge delay for an answer but I was in a rush
y’know, undergraduate life :sweat_smile:

but it worked, using Http to get the file

thank you very much!