Skip to content

Instantly share code, notes, and snippets.

@alexferreira
Created November 23, 2010 15:52
Show Gist options
  • Save alexferreira/711970 to your computer and use it in GitHub Desktop.
Save alexferreira/711970 to your computer and use it in GitHub Desktop.
def import
render :layout => false, :nothing => true
arquivo = "#{Rails.root}/Workbook1.csv"
#puts Benchmark.measure {
Tvschedule.transaction do
FasterCSV.foreach(arquivo, :encoding => 'u') do |row|
data = Time.parse(row[1]).strftime("%Y-%m-%d")
canal = Channel.where(:name => row[0]).select(:id).first
@tvschedule = Tvschedule.create
@tvschedule.channel_id = canal.id
@tvschedule.data = data
@tvschedule.hora = row[2]
@tvschedule.produto = row[3]
@tvschedule.titulo_original = row[4]
@tvschedule.titulo = row[5]
@tvschedule.numero_episodio = row[6]
@tvschedule.temporada = row[7]
@tvschedule.pais = row[8]
@tvschedule.ano = row[9]
@tvschedule.diretor = row[10]
@tvschedule.elenco = row[11]
@tvschedule.sinopse_produto = row[12]
@tvschedule.sinopse_titulo = row[13]
@tvschedule.formato = row[14]
@tvschedule.genero = row[15]
@tvschedule.sub_genero = row[16]
@tvschedule.classificacao_etaria = row[17]
@tvschedule.save
end
end
#}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment