Skip to Content

Read the data from CSV File

Hello Experts,

In my project i came  across a requirement where there are lots of records in a CSV file and i have to create all the records using Batch Operation upon clicking the upload button.

Can you please help me how to read the data of the file in the runtime , what i feel is that i have to know the url of my local file first and then read the file data using AJAX but am not getting any clue for how to get the url of the file during run time.

Please help me in this.Thanks in advance.

Regards,

Vikash

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Oct 16, 2015 at 11:45 AM

    Hi Vikash,

    <FileUploader xmlns="sap.ui.unified" 

      uploadUrl="" 

      buttonText="{i18n>detailBtnImport}" 

      fileType="csv" 

      maximumFileSize="1" 

      buttonOnly="true" 

      icon="sap-icon://upload" 

      change="onChangeFUP" 

      uploadComplete="onUploadCompleteFUP" 

      typeMissmatch="onFailedFUP" 

      fileSizeExceed="onFailedFUP" 

      uploadAborted="onFailedFUP" 

      filenameLengthExceed="onFailedFUP"/> 

    onChangeFUP : function(e) { 

      this._import(e.getParameter("files") && e.getParameter("files")[0]); 

    }, 

    _import : function(file) { 

      if(file && window.FileReader){ 

      var reader = new FileReader(); 

      var that = this; 

      reader.onload = function(e) { 

      var strCSV= e.target.result; //string in CSV 

      };reader.readAsText(file); 

    Refer from :

    @Raman Sharapinski Comment.

    var strCSV= e.target.result; //string in CSV - Here you will get your csv file records



    Thanks,

    Karthik A

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Karthik,

      Thanks for the reply.The Import Function which you mentioned that should trigger when i click on upload button right?or this should be triggered in some event of file uploader.

      Please let me know so i can proceed with it.

      Regards,

      Vikash