# Having problem with spliting record

**URL:** <https://www.ruby-forum.com/t/having-problem-with-spliting-record/116931>\
**Category:** Rails\
**Created:** [October 11, 2007, 11:36am UTC](https://www.ruby-forum.com/t/having-problem-with-spliting-record/116931 "2007-10-11T11:36:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vidyagayathri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/ba9def/32.png) [@vidyagayathri](https://www.ruby-forum.com/u/vidyagayathri)\
**Post date:** [October 11, 2007, 11:36am UTC](https://www.ruby-forum.com/t/having-problem-with-spliting-record/116931/1 "2007-10-11T11:36:05Z")

</div>

Hi all,

My problem is i have to remove the “~” value from the last end of the  
record, actually first i will read from the file, while reading the file  
i have remove this “~”

1)LIN_EDIA000005_000000570_570_0697_RC_SHEPLER’S EXCLU_100_SHEPLER’S  
EXCLUSIVE_6042142403_SHEPLERS COGNAC HORNBACK CAIMAN  
TAIL_20070719_20070719 **02_724178914197_** _**070  
A**_\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*50384~

2)LIN_EDIA000005_000000570_570_0697_RC_SHEPLER’S EXCLU_100_SHEPLER’S  
EXCLUSIVE_6042142403_SHEPLERS COGNAC HORNBACK CAIMAN  
TAIL_20070719_20070719 **02_724178711291_** _**110  
A**_\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*50544~

3)LIN_EDIA000005_000000570_570_0697_RC_SHEPLER’S EXCLU_100_SHEPLER’S  
EXCLUSIVE_6042142403_SHEPLERS COGNAC HORNBACK CAIMAN  
TAIL_20070719_20070719 **02_764556826704_** _**145  
A**_\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*50684~

```
At th 3 line end , i want to remove the "~", but i don't which

```

command to use it. my coding is

f = File.open(test,“r”)  
@aa=f.read()  
@a=@aa.split("~")  
@a.each do |v|  
@h=v.split("\*")  
end

Actually why i want to remove the last record means, when i am viewing  
in array , i will get one more extra empty record, otherwise please let  
me know, how to avoid the extra record. thanks 🙂
