How can I get information to a CSV file?

Hey everybody! Happy to be here.

Someone at - it a script very well commented that explains what's happening from one trying to get information on a CSV file?

I started a script, but I can't tell where I'm wrong. Here's what I'm trying to achieve:

1. I have a CSV file with ~ 100 lines. Each row has 5 pieces of data...

(Filepath 1. local to an image) (2 film title) (3. Runtime) (4. Side) (5. Description)

2. I try to select a random line of 100 (this is what I need help) and fill the data in a document active photoshop (I got this covered part).

Here's what I have so far, but I don't know that I'm heading in the right direction. I pointed out in some issues in the code. The random move does not work and I can't figure out how to get the data in a specific column into a variable. Someone at - it a preview?

var myCSV = new File('ENTER-FILEPATH-HERE/the-csv.csv'); myCSV.open('r');

function getRandomInt() {
return Math.floor(Math.random() * (99 - 2 + 1)) + 2;    }
while (!myCSV.eof)    { 

// myCSV.readln() only returns the data that is the last row in the CSV file, no matter what I put in the "()" How do I manipulate this? 
var lines = myCSV.readln(getRandomInt());   
var lineItems = new Array();    lineItems = lines.split(",");    }       

// My check to see what data I'm getting. I always get back the last row of data in the array.   
$.writeln(lineItems);       

// Does the [1] refer to the column to get the data from? Or am I misunderstanding this? How do I select the appropriate column to put into the variable?   
var arrImage = lineItems[1];   
var imageRef = File(arrImage);   

// This is where Photoshop gets hung up. The filepath isn't attached to the imageRef variable.   
var docRef = app.open(imageRef);

myCSV.close();

I appreciate any help!

Edit-formatting

File.Readln () does not take an argument. You need to read the entire file, split the file into lines, then pick a random row in this table. Something like:

function randomElement (ary) {}

return ary [Math.floor (Math.random (ary.length) * ary.length)];

};

var str = file.read ();

var str.split(/\r|\n/ = lines); This RegExp is not complete

var randomLine = randomElement (lines);

Tags: Photoshop

Similar Questions

  • How can I get information to reinstall windows vista?

    I had to replace a hard drive and install windows, but I lost the drive and other information that came with my laptop.

    How can I get information to reinstall windows?

    How to replace the Windows Setup disks depends on how you bought Windows.

    When you bought a copy of Windows retail:

    How to replace Microsoft software:
    http://support.Microsoft.com/default.aspx/KB/326246

    If Windows came with your computer - to replace the installation disks:

    Contact the OEM computer manufacturer and ask them to send you an installation to your computer disk - they may charge a small fee. Contact information for the manufacturer of your computer can be found here:

    http://support.Microsoft.com/GP/oemphone/

  • How can I get a copy of the file < windows > \system32\hal.dll.

    How can I get a copy of the file \system32\hal.dll.   ?

    There are 7 possibilities for the hal.dll file and the installation of XP takes the right one to match your hardware during the installation of XP.

    That's why replace a bit difficult because you need to know which of the 7 on the XP installation CD you need.  You can guess and try things and you might get lucky, or you can try them all.  That would take some time and probably be frustrating and you would need a CD bootable XP installation genuine to start the trials and errors.

    Replace the hal.dll file becomes even more difficult, because most of the people do not have a genuine XP bootable installation CD, even if they wanted to replace the hal.dll file.  If you really want just a copy, you can understand that one you need or just copy the one you already have.

    Unfortunately, the Microsoft Answers don't ask for enough information when a new question is asked to provide you with a good idea for your problem not specified.  For all that is your problem not specified, you will need to provide additional information.

    If you see the message that your hal.dll file is missing or damaged, the chances are that the file is not really missing or damaged... Windows XP just can not find the file.

    Fix hal.dll "missing or corrupted" message is usually not too demanding and has nothing to do with the replacement of the file.

    Maybe someday the dialog box 'ask a question' forums XP will ask these questions automatically when a new thread is started so I don't have to ask every time.  It might even be possible to solve a problem in a single response when enough information is provided.

    Please provide additional information on your system:

    What is your system brand and model?

    What is your Version of XP and the Service Pack?

    Describe your current antivirus and software anti malware situation: McAfee, Symantec, Norton, Spybot, AVG, Avira!, MSE, Panda, Trend Micro, CA, Defender, ZoneAlarm, PC Tools, Comodo, etc..

    The question was preceded by a loss of power, aborted reboot or abnormal termination?  (this includes the plug pulling, buttons power, remove the battery, etc.)

    The afflicted system has a CD/DVD drive work?

    You have a true bootable XP installation CD (it is not the same as any recovery CD provided with your system)?

    What you see you don't think you need to see?

    What do not you think that you should see?

    If the system works, what do you think might have changed since the last time it did not work properly?

  • How can I get information metadata... instructions?

    Hello world!

    How can I get instructions from metadata information.

    1.jpg

    Someone at - it correct this script.

    Code:

    var xmpString = app.activeDocument.xmpMetadata.rawData;

    If (xmpString! = null) {}

    Inst var = xmpString.match (/ (\s) < \/photoshop\:Instructions > < photoshop:Instructions > /);

    Alert (inst);

    }

    on the other

    Alert ("there is no metadata...!)

    Thanks in advance.

    -yajiv

    This requires Photoshop CS4 or better...

    #target photoshop
    main();
    function main(){
    if(!documents.length) return;
    var doc =activeDocument;
    if (ExternalObject.AdobeXMPScript == undefined)  ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
    xmpf = doc.xmpMetadata.rawData;
    xmp = new XMPMeta(xmpf);
    var Info = xmp.getProperty(XMPConst.NS_PHOTOSHOP, "Instructions");
    alert(Info);
    }
    
  • How can I get rid of the (trash) file a too big which is too large for the trash?

    I have a way to the leader of the corrupt photo library too big to the trash to manage.  If not, how can I get rid of him?

    Try to keep the Option key while emptying the trash.

    You can't empty the trash or move a file to the trash

  • How can I get the back windows of file I deleted - fwlink.asp

    I have Windows XP Edition version 2002 with Service Pack 3 family.  I did a virus scan.  During the analysis, I deleted a file that has been damaged by a Trojan Virus.  How can I get the file back.  This is the microsoft file fwlink.  I have lost the original supplied with my computer disks so I can't restore the computer.  Is there a way to get this file.  I don't have the MCSTRM service (event ID: 7000).  Your help is appreciated in advance.  Thank you.

    Hello

    Contact the computer manufacturer and ask them to send you to xp recovery discs to reinstall the operating system back as it was when you bought it

    they do it for a nominal cost of $

    How to replace Microsoft software or hardware, order service packs and replace product manuals

    http://support.Microsoft.com/kb/326246

    Here is the vista forums

    Try the forums xp on the link below

    http://answers.Microsoft.com/en-us/Windows/default.aspx#tab=4

    Answers by topic

  • How can I get the Organizer to display file names?

    I'm lost and confused in Photoshop 13. How can I get the names of files to display in the menu Organizer? I chose to keep the old version of the display "grid" and miss having the names of all files. I searched the manual online, but can't seem to find what I need!

    Please check options in the menu organizer of the following elements:

    View > Details

    View > Filenames

  • How can I get rid of the cache files?

    Premiere Pro, cannot find the files in cache on Mac, not in the common, clean folder does not work, I know there are concerts of them on my drive.  How can I get rid of them?

    I started a first project I had worked before using an external hard drive but I forgot to plug in the external drive.  In a few minutes, the first loaded 5 GB of cache on my macbook pro drive OSX 10.8.6 files.  I have tried the following to free space:

    Trying to 'clean up' the file cache before the switch to the external drive - it only removed a small amount of 5 concerts created

    Tried to find files in the folder Application Support/Adobe/common - no hidden files not found

    Tried searching the Web for answers - no new info

    Tried searching my drive for files - can not find them

    Tried to restart the MacBook and the first with and without the external hard drive - no luck

    Now what?

    Post edited by: Kevin Monahan

    Reason: Please do a shorter, more concise title next time. Thank you.

    First of all, exactly what first version are you running? Not just body CC or CC2014 but the version number shown in the about box.

    I don't understand if you tell first cannot find cache files or you are unable to find them.

    I think that you are referring to the own button in the Media tab of the Preferences dialog box, which is also where you set the path to the cache files.

    Are you sure you're looking in the correct library - not one that is easily accessible under Macintosh HD, but that than Apple, it of infinite wisdom, hide from users. To access it, open the menu go to, then press Option.

  • How can I get my scanner to scan files in format PDF version 1.4 or higher? They all scan in 1.3

    Hello

    Thanks for your help with this issue.

    I am scanning documents as PDF files and they are all scanned in version 1.3. What determines the version of the PDF? How can I get to analyze in the version 1.4 or higher? I have the latest Adobe Reader and my scanner is to update its drivers. The application that I am downloading the PDF file for does not accept version 1.3. I could convert all, but that creates another step and needs of my office to the analysis in the latest version and they will not all be updated each PDF. How can I update to get it to default to the latest version?

    Please help with this problem, I need in the older version to complete the necessary work of my with my business.

    Commercial scanner first - you'll want to speak with the vendor who provides the service.

    Individual scanners to local machines - Franklin; same provider but different models or different suppliers - either would mean resolution individual, piecemeal.

    If they're "desktop" then someone ' one - somewhere should have custody of the CD / DVD that came with the devices (.. .they are "assets of the company, no?).

    Be well...

  • How can I get information about the employee transfers and promotions in HRMS

    Hello dear colleagues,

    I will be grateful if someone could show me the way to get into the transfers of employees and promotions within the HRMS module. My company uses oracle Release 11i applications and we would like to migrate our historical data on the employee transfers and promotions. These historical data are currently held in Microsoft Access. So, for example, an employee named John James has the history of following Promotion:

    Grade , Start_date , End_date
    Agent II, June 1, 1995, 31 December 1999
    Agent I, January 1, 2000, 31 December 2003
    Asst. Mgr, January 1, 2004, December 31, 2007
    January 1, 2008, Bishop DEP., so far

    Similarly, Mr. John James was transferred to different departments within the Organization in accordance with the following table:

    Dept , Start_date , End_date
    I.T. dept, 1 June 1995, 30 August 2004
    Research dept, August 31, 2004, December 12, 2004
    Finance dept, August 13, 2004, 9-Sep-2008
    I.T. dept, 10-Sep-2008, 31 March 2011
    Dept of Habay, April 1, 2011, to date

    How can get us these historical data on Mr. John James. If we can do that and also to determine the name of the table/tables oracle used to store the information, write to us and use Microsoft Access queries with odbc to migrate data in oracle.

    I'll be very grateful if someone could make a little time to show me how to do this. Thank you in advance.

    -Emmanuel Lawson

    Published by: user6417506 on January 10, 2012 03:17

    You can download employee assignment of data to aid allocation API backend (HR_ASSIGNMENTS_API).
    Here are ways to assignment data (job, Position, Department, Grade).

    You convert your data to the format assignment

    As
    Rank of Dept
    June 1, 1995 to December 31, 1999, IT Officer II
    January 1, 2000 to December 31, 2003 IT OfficerI
    January 1, 2004 to August 31, 2004 research officer I have

    You must first configure all these data in sttucture of work as Department and grades in the system before loading the responsibilities of the employee.

    The data stored in the PER_ALL_ASSIGNMENTS_F table.

    Thank you

  • How can I get information RTE in operator (LV) of TS API interface?

    Hello!

    I have operator interface in Labview and use TS API to run tests.

    I like to remove dialogue TEN and see the error messages directly in front panel controls.

    I created the reminder for the TS Application Manager BreakOnRTE event.

    It works well and I can lock apearance of dialogue.

    But if I try to get event parameter ErrorObject (execution) is empty (no error information has).

    But this is real execution that contains step with RTE.

    During the appearance of the dialog box allow in this callback, it contains information of RTE.

    Where can I get the error of this recall information or get it everything else?

    Thanks in advance for any help.

    I found the way to get reminder RTE BreakOnRunTimeError of ApplicationMgr.

    In this way is:

    Run-> GetThread [0]-> GetSequenceContext [0]-> GetRuntimeErrorMessageEx().

    It was not unclear to me: all fields error in step and sequence do not yet meet at the time of reminder.

    Only the context method may return the error message.

    The issue is closed.

  • How can I get information about the history of corporate 6.3.1 users

    Need help on the following points. Since I'm a guy HFM and don't have no business touching for awhile, I need help on the following points:


    We want to have a report that shows the history of users re: date and time users log in and out of each application Hyperion 6.3.1.

    Where can I get this information? Thought to look in the file < application > .use but not able to see it properly using a text editor.

    Company has not all newspapers following connection/disconnection information. Optionally, check the error log for the first activity that a user performs for example:
    data refresh or the loading of data, that contains the date and time of execution, but it will require filtering of data.

  • How can I get information on a search engine installed?

    I want to see what exactly search engines I installed, for example by seeing the page add-on from the respective search engine. How can I do this?

    Which does not exist in Firefox for searches on the search bar or to the plugins you have installed. Look on the Internet using a search engine if you need comments. Or on the search engines home & support pages for features and descriptions.

    Details of the research that I mentioned is simply the code to make the research available and is conveniently divided into a file by search engine and therefore lists the available search engines. For example, the default is Google. Even with your plugins, they are third party definition software, but in the case of the plugins YOU have installed and selected.

    You can add searches Mycroft (http://mycroftproject.com/search-engines.html) as mentioned in the article linked, and they at least kinds for most downloaded. Even if you use addons hosted on addons.mozilla.org where you will see reviews and ratings.

  • How can I get a list of nominal files in folders/subfolders?

    I use a star rating system to select the pictures I need to work on. Each topic has its own folder. In each topic folder are subfolders, one for every time I have a photo shoot with them. The hierarchy looks something like this...

    Appear

    Topic1

    Shoot1

    Shoot2

    Matiere2

    Shoot1

    Subject3

    Shoot1

    Shoot2

    Shoot3

    Shoot4

    Sujet.4

    Shoot1

    And so on. The image files are in each folder 'Shoot '. The thing I want to accomplish is to have a way that I can start with the main folder and check through all subfolders where image files are, and build a list of all the files of the assigned image I can analyze thanks to see that I need to work on the images.

    Ideally I would have sorted highest to lowest side. I can do this through each folder and file inside, checking the side of each file and continues. What I really prefer to speed things up is to know if there is a way to check the contents of the folder and filter in notation. First, extract all 5 star rated file names, then 4 stars, then 3 stars and so on. I can't find anything in the documentation for the bridge script which allows to sort/filter the contents of the folder. I currently have more 40 000 files image then consulted through them one at a time even with a script would be a task that is why I would like to know if there is a method to filter the sides in the script files.

    Any help would be greatly appreciated. I can write the script... at least the majority of it I think... but things would be so much more enjoyable for me with a filter/sort.

    Yes it loop through all the files, but it should not take too long because the bridge will not be cached all the files.

    If it is a long process, you could write the list of records in a file and process a little at a time.

    Good luck!

  • BluetoothSerialPortListener: How can I get information about existing ports?

    Hello

    I need information (packets sent/received) on the activities of bluetooth on a device and found the net.rim.device.api.bluetooth and the javax.bluetooth package. The samples that I found all Creation/use own bluetooth Manager and to implement their own methods of send/receive (so they can count themselve ). But I somehow tuned to the existing/default; I couldn't find out how.

    I also tried to use the RadioStatusListener, but it does not manage the bluetooth?

    Please give me some tip! Thank you

    There is no support for this within the set of APIs of BlackBerry.  An application cannot access Bluetooth connections made from other applications.

Maybe you are looking for