From: Robert Klemme Date: 2010-03-19T01:29:44+09:00 Subject: Re: Replace Text at Specific Positions Across Files 2010/3/18 Shiny Hydra : >> 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/