please select your own LANGUAGE

Saturday, January 31, 2015

Importing data sets from external files

    You can quickly create a large number of data sets by creating an external text file that contains all the variable information and loading that file into a PSD document containing variables. One good way to accomplish this is to enter your data into a text file and then export it to a tab or comma-separated file.
    The syntax of the external text file is as follows (where each line that starts with "Variable" or "Value" is an entire line by itself in your file):
    VariableName1<sep>VariableName2<sep> <sep>VariableNameN <nl>
    Value1-1<sep>Value2-1<sep> <sep>ValueN-1<nl>
    Value1-2<sep>Value2-2<sep> <sep>ValueN-2<nl>
    Value1-M<sep>Value2-M<sep> <sep>ValueN-M<nl>
    All the variable names are listed on the first line, in the order that the values are given in subsequent lines. Each subsequent line represents one data set, with the values for each variable given.
    External Text File Syntax Elements
    <sep>
    Either a comma-separated (CSV) or a tab (tab-delimited) file that separates each variable name or value.
    <nl>
    A newline that ends each data set and can be a line feed, carriage return, or both.
    "true" and "false"
    Allowed values for a visibility variable.
    Spaces
    Around the delimiter are removed when parsing the file; between words in a value string (e.g., two of a kind) are maintained and leading and trailing spaces are maintained if enclosed in double quotes (e.g. , "one kind ").
    Double quotes
    Can be part of a value if preceded by another double quote (e.g. , ""B"" would be "B" in the data set).
    If <sep> or <nl> is part of the variable value, then the entire value must be enclosed in double quotes.
    All variables defined in the PSD document must be defined in the text file. An error will be displayed if the number of variables in the text file does not match the document.
Example data set:
    Using a template for flowers that holds variables for tulip and sunflower, you can set up a text file that looks like this:
    {contents of FlowerShow.txt}
    Variable1, Variable2, Variable3
    true, TULIP, c:\My Documents\tulip.jpg
    false, SUNFLOWER, c:\MyDocuments\sunflower.jpg
    false, CALLA LILY, c:\My Documents\calla.jpg
    true, VIOLET, c:\My Documents\violet.jpg
To import a data set:
  1. Do one of the following
    • Choose File > Import > Variable Data Sets.
    • Choose Image > Variables > Data Sets.
  2. Click the Import button.
  3. Enter the name of the text file to import.
  4. Set up your import options. There is a check box to use the first column value as the data set name. This is useful if your first variable is an identifier like a name or product number and you want to name your data sets with that value. Otherwise, the data sets are named "Data Set 1, Data Set 2, etc.." There is also a check box to delete all current data sets before importing new data sets.
  5. Set the encoding of the text file or leave as "Automatic."
  6. Click OK.

No comments:

Post a Comment