Hi,
How do you remove empty rows from a table?
And how to you convert a table into a matrix?
I've tried using
if @isempty(sigbeta(!i,1)) = 1 then
sigbeta.deleterow(!i)
for the first part but it doesn't work.
Delete Empty Rows from a Table
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Jason
- EViews Developer
- Posts: 870
- Joined: Tue Sep 16, 2008 3:50 pm
Re: Delete Empty Rows from a Table
When you say the first part is not working, do you mean the 'if' statement? This may be intentional, but the code you posted is only checking to see if the first cell in the row is empty. To check an entire row you will need to loop through the remaining cells in the row and verify they are also empty. I otherwise don't see anything wrong with your code.
NOTE: if the cell in the table only contains spaces, it may appear to be empty but it is not
There isn't an easy way to convert a table to a matrix. You would have to know ahead of time the size of the resulting matrix and then copy over 1 cell at a time.
NOTE: if the cell in the table only contains spaces, it may appear to be empty but it is not
There isn't an easy way to convert a table to a matrix. You would have to know ahead of time the size of the resulting matrix and then copy over 1 cell at a time.
Re: Delete Empty Rows from a Table
Thanks Jason.
When I said it didn't work, I meant that the code runs properly but the rows don't get deleted. E.g.
[blank]
[blank]
ABC
[blank]
DEF
GHI
could end up with
[blank]
ABC
[blank]
DEF
GHI
Sometimes the blanks are gone but other times they remain. I suspect it's because when I use deleterow, the value of !i also changes so the next deleterow could be reading the wrong line. Is this the reason?
For the 2nd part, how do I calculate the no. of rows/members in a table then?
When I said it didn't work, I meant that the code runs properly but the rows don't get deleted. E.g.
[blank]
[blank]
ABC
[blank]
DEF
GHI
could end up with
[blank]
ABC
[blank]
DEF
GHI
Sometimes the blanks are gone but other times they remain. I suspect it's because when I use deleterow, the value of !i also changes so the next deleterow could be reading the wrong line. Is this the reason?
For the 2nd part, how do I calculate the no. of rows/members in a table then?
Re: Delete Empty Rows from a Table
Oh Jason, I found anyway to do it. Thanks!
Re: Delete Empty Rows from a Table
Hi! Jun said he found a solution but did not mention which one.
So because it can be useful for other users, I post my own solution here.
The way I deal with a similar issue is by running the loop in reverse:
for !nbrow=@rows({%nametable}) to 2 step -1
if {%nametable}(!nbrow,1)="" 'here is my condition, but it can be wathever condition
{%nametable}.deleterow(!nbrow) 1
endif
next
So because it can be useful for other users, I post my own solution here.
The way I deal with a similar issue is by running the loop in reverse:
for !nbrow=@rows({%nametable}) to 2 step -1
if {%nametable}(!nbrow,1)="" 'here is my condition, but it can be wathever condition
{%nametable}.deleterow(!nbrow) 1
endif
next
Who is online
Users browsing this forum: No registered users and 2 guests
