Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2013
    Posts
    6

    Answered: How can I capture input filename when using an import parser?

    My database maintains a list of items each with 4 pieces of information and 5 additional created fields. The raw list is complied in an excel spreadsheet, converted as needed and exported to a csv file which is then imported and parsed by my BD database. The parser reads the csv file, comparing each item to the existing BD list and adds any new items to the database. Each new record has a field tracking the creation date (so I can track which segment of the list is being modified), and a field tracking the source csv file. Thus far I have manually entered the source filename after the import and parsing has completed. I would like to capture the source filename and enter it into the field during the parsing process. Any clues?

  2. Best Answer
    Posted by Tubbritt

    "Hello.
    Yeah, this is easy to do. There's actually a stupid typo in the manual that has probably put you on the wrong path here.

    Anyway.... One way would be that if you have a button or a menu item that you are pressing to activate the parse function, you can add 2 lines of code before that function is activated that will populate two variables.

    For example, create your menu button.

    Line one of your code should be a new variable that is set by User Input. When you select “User Input” choose “Set var by open file dialog”. Give this variable a name called “path” and make it a Global Variable. This will basically store the full path to a file you select later on.

    For line two of your code, we want to trim information stored in the variable “path” above and extract only the actual file name. To do this, add another global variable. This time add a text variable and lets call it “file”. Now populate the text formula box of that variable with this code.

    [$path^text FILE;]

    This will strip away the path and leave you with only the file name in this variable.

    So at this stage we have two lines of code.
    Line 1 asks you want file you want to work with and it remembers the path.
    Line 2 reads the path and extracts only the file name from the path.

    Line 3 of your code should now be to run your import/parse template. However you need to modify your template so that there's no need to set the path to the file for this line of code as we did this already with line 1. You can do this by editing your template and setting the path to [$path] in your template. You will have to manually type that into the path field of your template. This way line 1 of your code sets the path for line 3 to work with.

    You can also modify you template now so that for each record imported it populates Line 2 (the file name) into a field of each record as you wanted.

    Regards
    James"


  3. #2
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Hello.
    Yeah, this is easy to do. There's actually a stupid typo in the manual that has probably put you on the wrong path here.

    Anyway.... One way would be that if you have a button or a menu item that you are pressing to activate the parse function, you can add 2 lines of code before that function is activated that will populate two variables.

    For example, create your menu button.

    Line one of your code should be a new variable that is set by User Input. When you select “User Input” choose “Set var by open file dialog”. Give this variable a name called “path” and make it a Global Variable. This will basically store the full path to a file you select later on.

    For line two of your code, we want to trim information stored in the variable “path” above and extract only the actual file name. To do this, add another global variable. This time add a text variable and lets call it “file”. Now populate the text formula box of that variable with this code.

    [$path^text FILE;]

    This will strip away the path and leave you with only the file name in this variable.

    So at this stage we have two lines of code.
    Line 1 asks you want file you want to work with and it remembers the path.
    Line 2 reads the path and extracts only the file name from the path.

    Line 3 of your code should now be to run your import/parse template. However you need to modify your template so that there's no need to set the path to the file for this line of code as we did this already with line 1. You can do this by editing your template and setting the path to [$path] in your template. You will have to manually type that into the path field of your template. This way line 1 of your code sets the path for line 3 to work with.

    You can also modify you template now so that for each record imported it populates Line 2 (the file name) into a field of each record as you wanted.

    Regards
    James

  4. #3
    Join Date
    Mar 2013
    Posts
    6
    James,

    Thanks!
    Updating the button and template now.

    Donna

  5. #4
    Join Date
    Jul 2012
    Location
    Ireland
    Posts
    815
    Provided Answers: 17
    Great, if you get stuck just let me know. I can throw together a quick example to look at.

    Regards
    James.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •