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
 Filling blank cells with the previous cell value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rowed79

USA
4 Posts

Posted - 08/19/2013 :  10:34:17 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release : OriginPro 9.0.0
Operating System: Win7 Pro SP1

Hello,

I have a column of data which only fills the cell when there's a change in the previous value. However, I need to have all the cells in the column filled, such that if there's a blank cell, it's filled by the value of the cell directly above it. I'm trying to write this into a simple script that I can run in LabTalk during a batch import using the import wizard. This is my first attempt, acknowledgedly poor:

if (col(b)[i] == NANUM) col(b)[i] = col(b)[i-1];

Full disclosure, I'm a LabTalk novice at best, but I'm trying to learn quickly. Any help would be very much appreciated.

Regards,
Dave

--Dave

greg

USA
1378 Posts

Posted - 08/19/2013 :  4:51:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Assuming that the first row always has a value, the script could be:
range rab = col(b);
val = rab[1];
loop(ii,2,rab.GetSize())
{
if(rab[ii]==NANUM) rab[ii]=val;
else val = rab[ii];
}

Otherwise you can pick some arbitrary value:
range rab = col(b);
val = 0; // This be used until a real value is found
loop(ii,2,rab.GetSize())
{
if(rab[ii]==NANUM) rab[ii]=val;
else val = rab[ii];
}
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