# Ruport, Table append, access to record

**URL:** <https://www.ruby-forum.com/t/ruport-table-append-access-to-record/86773>\
**Category:** Ruby\
**Created:** [February 25, 2007, 8:05pm UTC](https://www.ruby-forum.com/t/ruport-table-append-access-to-record/86773 "2007-02-25T20:05:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 25, 2007, 8:05pm UTC](https://www.ruby-forum.com/t/ruport-table-append-access-to-record/86773/1 "2007-02-25T20:05:34Z")

</div>

I’m looping through an Excel spreadsheeet, acquiring cells, and adding  
the data to a ruport table. I want access to the record just  
appended, but unsure of how to get to it. Code follows:

```
     begin
        @tbl_PAS << { # append row into table
            :clientid =>

```

get\_cell\_as\_text(row,@buildlist[:clientid]),  
:wdatetime =\>  
get\_cell\_as\_date(row,@buildlist[:wdatetime]),  
:emp =\> emp\_merge(row),  
:whours =\> get\_cell\_as\_num(row,@buildlist[:whours]),  
…  
}  
rescue  
puts “Unexpected error inserting data into table.”  
puts options.inspect  
raise  
end

```
     # tag record for summary counts
     case
     when r.proj[0,4] == 'ADMN'
        r.tag(:Administration)
     when r.task[0,5] == 'AL916'
        t.tag(:Support)

```

…

I want r. to the last record appended. I was hoping r = @tbl\_PAS \<\<  
would be it. But r points to the table, not the last record appended.

Any advice?  
dvn

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 25, 2007, 8:31pm UTC](https://www.ruby-forum.com/t/ruport-table-append-access-to-record/86773/2 "2007-02-25T20:31:03Z")

</div>

I’ve attempted the following, but it is not buying it. I get a tassoc  
error?

```
        r = Ruport::Data::Record.new {
            :clientid =>

```

get\_cell\_as\_text(row,@buildlist[:clientid]),  
:wdatetime =\>  
get\_cell\_as\_date(row,@buildlist[:wdatetime]),  
:emp =\> emp\_merge(row),  
:whours =\> get\_cell\_as\_num(row,@buildlist[:whours]),  
…  
}

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 25, 2007, 8:38pm UTC](https://www.ruby-forum.com/t/ruport-table-append-access-to-record/86773/3 "2007-02-25T20:38:05Z")

</div>

On 2/25/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I want r. to the last record appended. I was hoping r = @tbl\_PAS \<\<  
> would be it. But r points to the table, not the last record appended.

try:

r = @tbl\_PAS[-1]

This should do the trick.

For further questions, please come catch up with us on the Ruport list.  
[http://list.rubyreports.org](http://list.rubyreports.org)

-greg

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 26, 2007, 12:46am UTC](https://www.ruby-forum.com/t/ruport-table-append-access-to-record/86773/4 "2007-02-26T00:46:25Z")

</div>

On Feb 25, 1:37 pm, “Gregory B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> For further questions, please come catch up with us on the Ruport list.[http://list.rubyreports.org](http://list.rubyreports.org)
> 
> -greg

Thanks. Sometimes “too easy” makes one feel really dumb. I’m trying  
to exploit all the capabilities of Ruport’s tabling handling – and  
struggling. I don’t know why this is seeming so difficult. I now get  
an error when using group\_by\_tag. In my data load, I’ve done the  
following:

def apply\_category(r)  
case  
when r.proj[0,4] == ‘ADMN’  
r.tag(:Administration)  
when r.task[0,5] == ‘AL916’  
r.tag(:Support)  
when (r.task[0,2] == ‘IS’ or  
r.proj == ‘76011’ or  
r.proj == ‘75634’ or  
r.proj == ‘75638’)  
r.tag(:Development)  
else  
r.tag(:Other)  
end  
end

When I attempt to utilize those tags, things go south. I’ve  
attempted:

def cat\_hours(c)  
hrs = 0  
t = @tbl\_PAS.group\_by\_tag(c)  
#@tbl\_PAS.group\_by\_tag(:Development).each {|r| hrs += r.whours}  
printf “%-15s = %5.2f\n”,c,hrs  
end

But I am typically greeted with “Exception: undefined method  
`group\_by\_tag’ for #Ruport::Data::Table:0x2d6c700”

If you have any suggestions, that would be much appreciated. What I  
am doing is attempting to deal with the increased time reporting  
demands of my company. Their time tracking system is dismal, but it  
exports data to Excel. So I want to table everything, categorize it  
at will, and produce six or seven different summaries from the various  
data elements available.

thanks again,  
dvn

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 26, 2007, 1:00am UTC](https://www.ruby-forum.com/t/ruport-table-append-access-to-record/86773/5 "2007-02-26T01:00:26Z")

</div>

On Feb 25, 2007, at 5:45 PM, removed\_email\_address@domain.invalid wrote:

> On Feb 25, 1:37 pm, “Gregory B.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > For further questions, please come catch up with us on the Ruport  
> > list.[http://list.rubyreports.org](http://list.rubyreports.org)

> I’m trying to exploit all the capabilities of Ruport’s tabling  
> handling – and struggling.

You might really want to consider taking Greg’s advice then and  
asking the Ruport list directly. I don’t say that to be mean, I’m  
just betting the people there are much more likely to know the exact  
answers to your questions. (I don’t sadly, or I would answer them.)

I know Greg tries to keep one eye on Ruby T., but I’m sure he  
misses some things. He sees every single message on the Ruport list  
though, as do numerous other experienced Ruport users.

The list is a Google Group, so you can interact with it completely  
from their web interface and not have to hassle with more email  
messages. I always find that nice when I just want to ask a few  
questions.

Anyway, just a thought. Good luck with your report.

James Edward G. II
