Read CSV file in ARAS in ClientSide/Javascript

Hello mates, I have a clumsy day today. I am trying to read an excel file, I have read that it could not be done, so I will try it with a CSV file.

I've looked all over the forum and Google, but I can't find the key to make it work for me.

In this forum I have seen several similar questions, but I have tried all the codes posted and they do not work for me.

One of the codes I tried is this:

var vault = top.aras.vault;
var fileName = vault.SelectFile();
alert(fileName);
var fileContents = vault.ReadText(fileName);
alert(fileConts);


But it returns the value:

[object Promise]

I have seen by google that the solution is:

var promise = Promise.resolve(fileContents);
alert(promise);

But it returns the same.

I have tried several examples from googe, but nothing. there is no way.
The PDFs of the documentation do not contain anything about it.

If it already gives me problems to load the file, I don't even want to imagine when "interpreting" the data.

Thank you so much!!.

Parents
  • OK!!!, i do it!. Works halfway!!!.

    I dont know why the code stops in the line 16.

    This code is similar to a post from Lucas. 2 years ago, and he did the same, he created a for and went through it with a rows.Length().
    In my case he does not get to execute that line of code. It stops before, if no error.

    aras.vault.selectFile().then(
    function (fileObject){
        file = fileObject;
        alert("Filename:" + file.name);
    
        var reader = new FileReader();
        reader.readAsText(file);
    
        // here we tell the reader what to do when it's done reading...
        reader.onload = readerEvent => {
            var content = readerEvent.target.result; // this is the content!
            alert("Contenido:" + content );
    
            var rows =content.split("\n");
            alert("registros: ");
            alert(rows[1]);   // the code stops here!!!!
            alert(rows.count());
            alert(rows.length());
    
            var i;
    
            for (i = 0; i < rows.length(); i++){
                alert("Entra en el FOR");    
        
                var parts_to_add =rows[i].split(";");
                alert(parts_to_add);
                alert(parts_to_add[0]);
            }
        }
    });
    

Reply
  • OK!!!, i do it!. Works halfway!!!.

    I dont know why the code stops in the line 16.

    This code is similar to a post from Lucas. 2 years ago, and he did the same, he created a for and went through it with a rows.Length().
    In my case he does not get to execute that line of code. It stops before, if no error.

    aras.vault.selectFile().then(
    function (fileObject){
        file = fileObject;
        alert("Filename:" + file.name);
    
        var reader = new FileReader();
        reader.readAsText(file);
    
        // here we tell the reader what to do when it's done reading...
        reader.onload = readerEvent => {
            var content = readerEvent.target.result; // this is the content!
            alert("Contenido:" + content );
    
            var rows =content.split("\n");
            alert("registros: ");
            alert(rows[1]);   // the code stops here!!!!
            alert(rows.count());
            alert(rows.length());
    
            var i;
    
            for (i = 0; i < rows.length(); i++){
                alert("Entra en el FOR");    
        
                var parts_to_add =rows[i].split(";");
                alert(parts_to_add);
                alert(parts_to_add[0]);
            }
        }
    });
    

Children