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
 multiple data file 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

ringman7677

USA
16 Posts

Posted - 01/15/2004 :  3:49:10 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I have ten (10 or more) separate ASCII data files that I want to merge into one worksheet (new rows). The trick is I need to adjust the first value in each column of the imported file to match up with the last value in the main worksheet file. This 'offset' would be applied to every value in the column. This same proceedure needs to be done with the next imported file and so on. I will admit I am not very proficient in script writing so any help would be greatly appreciated.

Mike Buess

USA
3037 Posts

Posted - 01/15/2004 :  8:57:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There are several ways to do that, but some of them depend on your Origin version. Since you didn't tell us that I'll suggest a method that should work in nearly any version. I must make two assumptions...

> Each file has the same number of rows (and columns, of course).
> By 'match up' you mean 'equal'.

If those assumptions are valid you can do this...

1. Create a new worksheet and select File->Import->Multiple ASCII.
2. In the file dialog choose Import each file as New Rows.
3. Select your data files and OK.

That will append all of your files as new rows to the same worksheet. The offsets can be introduced with the following LabTalk script...
nFiles=fdlog.multiopen.count; // # of files
get col(1) -e totalRows; // total # of rows
blockRows=totalRows/nFiles; // # rows per file
temp=data(1,blockRows); // create temporary data set
for(i=1;i<nFiles;i++) {
j1=i*blockRows; // final row index of the ith block
j2=j1+1; // first row index of next block
loop(k,1,wks.ncols) {
copy -b j2 wcol(k) temp -b 1 -t blockRows; // copy block to temp
temp = temp - temp[1] + wcol(k)[j1]; // offset temp
copy -b 1 temp wcol(k) -b j2 -t blockRows; // copy temp back to worksheet
};
};
del temp; // delete temporary data set


Mike Buess
Origin WebRing Member
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