0

I have many huge excel spread sheets (like 1000 files each having 65000 rows) and need to import into mysql. Should I use JAVA and use excel libraries? Should I do it in PHP? Can you give me sample code to just import a simple excel file into mysql table?

Thanks,

Amir

Sonic
  • 85
  • 1
  • 10

1 Answers1

0

If you use Ruby on Rails you can do:

require 'csv'    

csv_text = File.read('...')
csv = CSV.parse(csv_text, :headers => true)
csv.each do |row|
  row = row.to_hash.with_indifferent_access
  YourModel.create!(row.to_hash.symbolize_keys)
end
Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
  • 1
    Appreciate your help, but I never used Ruby, maybe one day I will give it a shot. For time being, I need it to be done in couple of days. – Sonic Mar 22 '13 at 22:43