This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I use this method to parse large csv files, clean the data and insert | |
# it in a database after some cleaning, it's pretty fast | |
# you can use it like this: | |
load_csv_data(PRELOAD_DIR+'socios.csv', 'users') do |csv, thing_id, row| | |
csv << [thing_id, | |
row['NOMBRE'].to_s.to_permalink+'.'+row['APELLIDOS'].to_s.to_permalink, # login | |
row['E_MAIL'], # email | |
row['SEXO'], # gender |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convert multibyte strings to an url-safe encoding | |
class String | |
def to_permalink | |
(Iconv.new('US-ASCII//TRANSLIT', 'utf-8').iconv self).gsub(/[^\w\s\-\—]/,'').gsub(/[^\w]|[\_]/,' ').split.join('-').downcase | |
end | |
end |
NewerOlder