--000e0cd1a99211b6740482190e32 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Mar 18, 2010 at 11:29 AM, Robert Klemme <shortcutter / googlemail.com>wrote: > 2010/3/18 Shiny Hydra <slotriof / guerrillamailblock.com>: > >> So your file has fixed width records? This is important to know, > >> otherwise approach 2 from below becomes tricky (you basically need to > >> read line by line in order to find the proper position whereas you > >> otherwise can calculate the position via record size). > > > > Yes, the records are all fixed width. The width of the file is based on > > the extension type. > > > >> Btw, is there a particular reason why you create what looks like a > >> relational database based on text files? > > > > I'm working off of a standard format that has been used for years > > (called Mail.dat). Editing the files has been an extremely time > > consuming process, so I'm trying to write an automated script to batch > > replace specific parameters. After doing some research, it seemed like > > Ruby was a great language to learn for this type of text manipulation > > and it turned out to be quite fun to boot. > > That's good! I hope you continue to enjoy your journey. > > > I'm currently working through the book Beginning Ruby: From Novice to > > Professional, but it does not go very in depth on text file manipulation > > techniques. I tried looking through the classes and methods online, but > > without a strong foundation in the language it's difficult to navigate > > that amount of information. If you could provide any additional > > information it would be immensely helpful. > > You could start with searching the archives of ruby-talk for "File" > and "seek". That should give you some bits of code which deal with > file IO different from sequentially reading or writing. > > Kind regards > > robert > > -- > remember.guy do |as, often| as.you_can - without end > http://blog.rubybestpractices.com/ > > This got me excited, my file manipulation isn't very good, so thought I'd give it a try. Here is what I got http://gist.github.com/336838 --000e0cd1a99211b6740482190e32--