0

I would like to know what would be the best way to automate the loading of an excel file into a mysql database.

The file would most likely be .csv, although, if there is a solution for text files, i can live with that. The data in to file would have to replace what is already in the database table.

I am searching for a solution meanwhile, and have found several for doing approximately this manually, as in, loading a file once, but i need this to happen every few minutes, if it is possible.

Cœur
  • 37,241
  • 25
  • 195
  • 267
John
  • 1
  • 1
  • possible duplicate of [Automate transfer of csv file to MySQL](http://stackoverflow.com/questions/5314271/automate-transfer-of-csv-file-to-mysql) or [Import CSV file directly into MySQL](http://stackoverflow.com/questions/4143938/import-csv-file-directly-into-mysql) – RandomSeed Jun 06 '13 at 09:56

1 Answers1

0

There is a native MySQL feature that allows importing a CSV file easily: LOAD DATA INFILE. All you need to do is declare your field- and line-separator correctly, if the default settings do not match your input file.

Please note that a CSV file is not an Excel file. It is a file format that Excel happens to be able to read.

If you really want to import Excel files (a .xlsx file, taht is), then you need some external library to first parse the Excel file, as MySQL is not able to read it natively.

RandomSeed
  • 29,301
  • 6
  • 52
  • 87