# Updating header in file

**URL:** <https://www.ruby-forum.com/t/updating-header-in-file/111136>\
**Category:** Ruby\
**Created:** [August 2, 2007, 11:08pm UTC](https://www.ruby-forum.com/t/updating-header-in-file/111136 "2007-08-02T23:08:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rorjeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rorjeff](https://www.ruby-forum.com/u/rorjeff)\
**Post date:** [August 2, 2007, 11:08pm UTC](https://www.ruby-forum.com/t/updating-header-in-file/111136/1 "2007-08-02T23:08:20Z")

</div>

I have a text file where the first line is the header  
being used by CSV. The second line to the end is data  
for each header. How can I append the header? The  
program I’m writing looks new entries in a data file  
and wants to add it to the end of the header. I’ve  
looked though CSV, file and IO and I don’t see what I  
need.

Thanks Jeff

```
  ____________________________________________________________________________________

```

Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user  
panel and lay it on us.  
[http://surveylink.yahoo.com/gmrs/yahoo\_panel\_invite.asp?a=7](http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7)

---

<div class="post-metadata">

**Author:** ![rorjeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rorjeff](https://www.ruby-forum.com/u/rorjeff)\
**Post date:** [August 2, 2007, 11:45pm UTC](https://www.ruby-forum.com/t/updating-header-in-file/111136/2 "2007-08-02T23:45:28Z")

</div>

On Aug 2, 3:07 pm, Jeffrey B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> ____________________________________________________________________________________
> 
> ```
> 
> Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user panel and lay it on us.[http://surveylink.yahoo.com/gmrs/yahoo\_panel\_invite.asp?a=7](http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7)

Jeff,

Can you please clarify and post an example of what you mean? Append  
the header to what?

Matt W.

---

<div class="post-metadata">

**Author:** ![rorjeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rorjeff](https://www.ruby-forum.com/u/rorjeff)\
**Post date:** [August 3, 2007, 12:28am UTC](https://www.ruby-forum.com/t/updating-header-in-file/111136/3 "2007-08-03T00:28:33Z")

</div>

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

> end of header = status#1, status#2, status#3  
> data line = 100, 60, — 55
> 
> new header end = status#1, status#2, status#3,  
> status#4  
> data line = 100, 60, 55  
> new data line = 100, 60, 55, 10

Is that actually how your data is structured? It’s not clear from the  
example.

---

<div class="post-metadata">

**Author:** ![rorjeff](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b9e5f3/32.png) [@rorjeff](https://www.ruby-forum.com/u/rorjeff)\
**Post date:** [August 2, 2007, 11:56pm UTC](https://www.ruby-forum.com/t/updating-header-in-file/111136/4 "2007-08-02T23:56:29Z")

</div>

end of header = status#1, status#2, status#3  
data line = 100, 60, — 55

new header end = status#1, status#2, status#3,  
status#4  
data line = 100, 60, 55  
new data line = 100, 60, 55, 10

Jeff

— Matt W. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > and wants to add it to the end of the header.  
> > I’ve  
> > looked though CSV, file and IO and I don’t see  
> > what I  
> > need.
> > 
> > Thanks Jeff

* * *

> > Fussy? Opinionated? Impossible to please? Perfect.  
> > Join Yahoo!'s user panel and lay it on

us.[http://surveylink.yahoo.com/gmrs/yahoo\_panel\_invite.asp?a=7](http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7)

> 

* * *

Fussy? Opinionated? Impossible to please? Perfect. Join Yahoo!'s user  
panel and lay it on us.  
[http://surveylink.yahoo.com/gmrs/yahoo\_panel\_invite.asp?a=7](http://surveylink.yahoo.com/gmrs/yahoo_panel_invite.asp?a=7)
