Uploading a CSV file to a variable

Moderator: Support

kevinmcisaac
Posts: 37
Joined: Mon Oct 05, 2020 8:27 am

Uploading a CSV file to a variable

Post by kevinmcisaac »

I want to upload a CSV file that is on my device into a variable in my app so I can processes it.

On the import page I added:

  • an <input type=file> which is bound to the variable filePath to set the filepath to load from.
  • an readonly <input> which is bound to the variable filePath to show the filepath variable.
  • A button that invokes the readFile service.
  • A readonly <input> bound to the variable csvData to show what is read by the service.
  • A readFile service where :
    ** the before mapping maps the the input filepath to the readFile service filepath .
    ** the success mapping maps the service request data to the variable csvData.

When I click on the input I see the files on my computer and select the file Parajournal.csv.

The issue seems to be the filepath is "C:\FAKEPATH\PARAJOURNAL.CSV.

When the service runs the csvData input shows the text "Hello world", which is not the csv data in the selected file.
Here is a video of this https://drive.google.com/file/d/1P7PNJ3 ... ez-gV/view

I tried this on my mobile device and got the same file path ( C:\FAKEPATH\PARAJOURNAL.CSV.) and no data is read into the variable. .

Evgene Karachevtsev
Posts: 12
Joined: Mon Apr 28, 2014 1:12 pm

Re: Uploading a CSV file to a variable

Post by Evgene Karachevtsev »

Hello,

Our readFile service is actually a Cordova plugin, so it doesn't work in a browser, it works only on a real device. In a browser, it returns mock data (please see TypeScript -> FileReadService_Impl line 29) You ca change it to work in a browser:
https://developer.mozilla.org/en-US/doc ... FileReader
https://www.javascripture.com/FileReader#readAsText

Post Reply