skip to Main Content

Just trying to read a CSV, as indicated in this post:

https://community.adobe.com/t5/photoshop-ecosystem-discussions/read-a-txt-file/m-p/3781245

But keep getting that error, why?

enter image description here

var prompt = "Elegir cuadro de materiales"
var filter = "*";
var multi_select = true;


var selectedFile = File.openDialog(["Elegir cuadro de materiales"], filter, multi_select);

alert(selectedFile);


selectedFile.open('r');

var dataToGet = selectedFile.readln();

selectedFile.close();

2

Answers


  1. Chosen as BEST ANSWER

    Results that openDialog with multiSelect set to true, returns an array.

    So, this solves the issue:

    var prompt = "Elegir cuadro de materiales"
    var filter = "*";
    var multi_select = true;
    
    
    var selectedFile = File.openDialog(["Elegir cuadro de materiales"], filter, multi_select);
    
    alert(selectedFile);
    
    
    selectedFile[0].open('r');
    
    var dataToGet = selectedFile[0].readln();
    
    selectedFile[0].close();
    

  2. You’ve solved your own problem, another way to do it is with a new File

    selectedFile = File.openDialog("Elegir cuadro de materiales","File:*.TXT", true);
    var myFile = new File(selectedFile[0]); //first in array
    myFile.open('r');
    // read the file here
    myFile.close();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search