The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Automatizing file re-import
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

LC_

42 Posts

Posted - 08/07/2013 :  10:57:26 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.5.0 SR1
Operating System: Windows 7

Hi

I have a project containing several imported files. I need to re-import the files - with same file names, but stored in a different folder in the server. I am trying to automatize this task with Labtalk but so far I haven't been successful.

Trying the code below,


doc -e LB
{
impinfo t:trInfo;
string strFName$ = trInfo.Info.FileName$;
trInfo.Info.FilePath$ = "C:\" + strFName$; //example path
reimport;
}

Changing the information on FilePath node will not update the path as read by reimport function and therefore the original file will be re-imported. Is there a workaround for this or should I consider using impFile instead (if it could work)?

thanks in advance

greg

USA
1378 Posts

Posted - 08/26/2013 :  09:30:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Unfortunately, Origin does not read that storage location to determine the file to reimport. Since you have the new file name, you should try the original import method, clearing the worksheet first...

impinfo t:trInfo;
string strFName$ = trInfo.Info.FileName$;
string fname$ = "C:\" + strFName$; //example path
clearworksheet %H;
impasc; // or other import function
Go to Top of Page

LC_

42 Posts

Posted - 09/17/2013 :  09:12:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Greg

Thanks for the answer. I managed to make it work, but there is only one thing that is not ideal yet. The files are imported with filters (files from different sources have different filters) and the script will loop through all the workbooks. If the filter names were stored as the file names are, I could retrieve them and send as parameter to "impfile" command. For some reason, however, the variable FILTER in SYSTEM.IMPORT tree is empty on all my filters. Therefore when I want to change the file path I always have to select the appropriate filter from the "Select Filter" dialog.

Is there a way to save the filter name during import? I hoped it would be automatic as the other parameters in SYSTEM.IMPORT.


ps. when I don't need to change the file path, I use the reimport function in my script and the filters are called up automatically - somehow reimport knows which filter was used.

Thanks again!
Go to Top of Page

greg

USA
1378 Posts

Posted - 09/18/2013 :  09:08:45 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The "Save file info. in workbook" check box on the "Variable Extraction" page of the Import Wizard is usually checked by default, in which case you could do the following to get the name of the filter file:
impinfo ipg:=[Book6]"Trial Run 3" tr:=tr;
strFilterFile$ = tr.FilterInfo.FileName$;
strFilterFile$=;

If the sheet is the currently active sheet you can omit the ipg argument.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000