Illustrator javascript CSV to Array to pathItems coordinates
I have a CSV File with the following data:
10, 23, 55, 123, 150 ...
I have a Javascript File which I use in Adobe Illustrator.
The following code creates 10 rectangles that are each shifted by 20 pixels and placed on the artboard. So far it works.
var myDocument = app.activeDocument; var artLayer = myDocument.activeLayer; var mypos = 0; var i = 0; while (i < 10) { var rect = artLayer.pathItems.rectangle( 0, mypos, 200, 600 ); i++; mypos = mypos + 20; }
Now I want to use the values from the CSV file for the coordinates/position of the rectangles instead of mypos + 20. The open dialog appears and I can select the CSV file. So far it works.
Now I don't know how to process the data from the CSV file and go through the array to use the values.
var csvFile = File.openDialog("Choose CSV file.", "*.csv"); var csvContents = ""; if (csvFile) { csvFile.open('r'); csvContents = csvFile.read(); csvFile.close(); }
