Author |
Topic |
|
ungat
Belgium
Posts |
Posted - 11/13/2005 : 4:31:44 PM
|
Origin Version (Select Help-->About Origin): 7.5 Operating System:Windows XP
Hello,
Could someone please tell me how import automatically several files(file1,file2,file3,...) which are located in X:\Directory\Fileswith a script window ?
Actually I use this script window: ------------------------------------------------------------------ run.section(Standard,NewWks); getfile *.*; open -w %b%a; %v=%h; ncols=%v!wks.ncols; %v!wks.col1.name$=Abs; for(i=1;i<=ncols-1;i+=1) { create %v_b$(i) 300; edit %v_b$(i); copy col($(i+1)) %v_b$(i); }; copy col(1) %v_a; for(i=1;i<=ncols;i+=1) { delete col(1); }; ------------------------------------------------------------------
But I have to select manually the directory and the filename to import and it takes more time;
I would like to import files with a script window in which I'll indicate the Directory path in which the files to import are located.
Thank you very much. |
|
eno
Japan
34 Posts |
Posted - 11/13/2005 : 9:09:11 PM
|
Hi ungat,
I also have the same needs and usually use the following script for this matter.
%r="X:\Directory\Fileswith\"; // path %s="file"; // file name %t=".csv"; // extension of ASCII file %u="result"; filenum=100; // Number of files that you have
win -t D; // New worksheet %v=%h; // Save name
ascimport.GetSettings(); // read import settings ascimport.renamewks=0; // avoid name change ascimport.WriteSettings(); // write settings
loop(ii,1,filenum) { win -a %v; open -w %r%s$(ii)%t;
// insert your script here
win -d %u$(ii); // copy results to new worksheet(result1,result2...) clearworksheet %v; // clear imported data };
win -cd %v; // remove %v
Hope to help. eno
|
|
|
ungat
Belgium
Posts |
Posted - 11/14/2005 : 06:17:55 AM
|
Thank you very much eno, but I didn't succeed use your script;
- first my files don't have extension (%t=".csv"; // extension of ASCII file ); it is simple file without extension.
- could you please give me a full example with 3 files (file1,file2 and file3) to import which are located in X:\Directory ?
Thank you again. |
|
|
ungat
Belgium
Posts |
Posted - 11/14/2005 : 06:39:47 AM
|
Thank you very much eno, but I didn't succeed use your script;
1) my files don't have extension (%t=".csv"; // extension of ASCII file ); it is simple file without extension.
2) my files don't have numero; it is not file1, file 2,...
it is file "toto", "blabla", "tata", and so there are not numeroted
- could you please give me a full example with 3 files (toto,zaza,lala) to import which are located in X:\Directory ?
Thank you again.
|
|
|
Mike Buess
USA
3037 Posts |
Posted - 11/14/2005 : 06:49:24 AM
|
This uses a multiple-file dialog...
fdlog.useGroup(""); if( fdlog.multiopen()==0/0 ) return; for(i=1;i<fdlog.multiopen.count;i++) { fdlog.get(A,i); // get file path\name win -t D; // open new wks open -w %A; // import file // more commands };
Mike Buess Origin WebRing Member |
|
|
ungat
Belgium
Posts |
Posted - 11/14/2005 : 07:12:01 AM
|
Hello Mike Buess, thank you very much,
but I don't make this, I want import files with a script window in which I indicate the path of directory in which the files are located:
example I would like to import files "AA","BB" and "CC" which are located in X:\Directory
Thank you again.
|
|
|
Mike Buess
USA
3037 Posts |
Posted - 11/14/2005 : 08:32:42 AM
|
The full path\name must be supplied as an argument for the open command...
open -w X:\Directory\AA;
You can import and manipulate repetitively like this...
%B=X:\Directory\; // directory %F=AA BB CC; // file list (space separated) for(ii=1;ii>0;ii++) { %A=%[%F,#ii]; // get next file name if(%A=="") break; win -t D; open -w %B%A; // more commands };
Mike Buess Origin WebRing Member |
|
|
|
Topic |
|