From: James Edward Gray II Date: 2009-11-18T04:19:05+09:00 Subject: Re: Special characters in csv header using fastercsv On Nov 17, 2009, at 12:58 PM, John Mcleod wrote: > In your code... > :header_converters => lambda { |h| h.tr(" ", > "_").delete("^a-zA-Z0-9_")}, > > what is happening here? > h.tr(" ", "_").delete("^a-zA-Z0-9_#") > > it looks like you're checking a table row for an instance of " " and > replacing with "_" tr(), for transliterate, is used to replace characters. You are right that I'm using it to switch all spaces to underscores. > but I'm unsure of the ".delete("^a-zA-Z0-9_")" delete() allows me to list characters I want to remove. It understands simple ranges, like a-z and 0-9. Also, if the first character is a ^, the entire character set is negated. Thus my call means delete all non letters, numbers, and underscore characters. James Edward Gray II