From: James Gray Date: 2009-06-18T07:26:23+09:00 Subject: Re: Regexp for CSV header On Jun 17, 2009, at 10:31 AM, Paul Shapiro wrote: > My script currently is processing various csv files. I recommend using a CSV parser so it can worry about all of those little details for you. Here's an example script to give you ideas: #!/usr/bin/env ruby -wKU require "rubygems" require "faster_csv" # read a line of CSV fields = FCSV.parse_line(DATA.read) # edit the fields fields.each do |f| f.sub!(/\A\d+\)\s*/, "") end # show fields puts fields # write back out as CSV puts FCSV.generate_line(fields) __END__ Device ID,1) S31 Which best describes how you answered the online reading comprehension quiz?,2) S32 Which best describes how you answered the online timed retrieval quiz?,3) B19. If you want your product to be easy to find in the supermarket then you should make its container,"4) C19. So that he can shift attention between the radio and his incessantly talking girl friend when she is in the car, Joe adjusts his radio",5) B20. Early selection is most likely to occur for,6) C20. Early selection for a red target is most likely to occur when there is,"7) B21. In a lexical decision task, when the target is a bird name, e.g. robin, it is usually preceded by the prime BODY but is sometimes preceded by the prime BIRD." Hope that helps. James Edward Gray II