4 messages in com.mysql.lists.win32RE: Excel to MySQL...
FromSent OnAttachments
Sergio Augusto Bitencourt Petrovcic14 Nov 2001 20:24 
Robbert - Jan van Velzen15 Nov 2001 02:12 
Jonathan Ball (acsjob)15 Nov 2001 02:51 
Nick Tentomas15 Nov 2001 03:39 
Subject:RE: Excel to MySQL...
From:Jonathan Ball (acsjob) (j.b@rgu.ac.uk)
Date:11/15/2001 02:51:45 AM
List:com.mysql.lists.win32

Robbert's way is good and, just to give you some alternative to choose from, here are another couple of ways:

BULK COPY PROTOCOL METHOD 1) Save you Excel as a text file (use comma delimited for ease). Save the text file with the same name as the name of your table in MySQL. In this case your exported text file would look something like this:

"Smith","John","Mr","1234 Main Street","Bigsville","Private Detective" "Brown","George","Mr","24 The Grange","Old Town","Rodent Erradication Operative" "Jenkins","William","Dr","1534 Seaview Avenue","Smallsville","Dentist"

2) Create a table in MySQL with the appropriate fields. 3) Then, use MySQL's "mysqlimport" utility (which resides in the /mysql/bin directory) to bring in your data. From the DOS/Unix prompt type the following (assuming you are in your MySQL directory):

bin/mysqlimport -fields-enclosed-by=" -fields-terminated-by=, MyDatabase MyNewTable.txt

This loads the entire content of a text file called "MyNewTable.txt" into the table called "MyNewTable" in the database called "MyDatabase". There are a large number of options for this command which I will not attempt to list here.

LOAD DATA INFILE METHOD 1) Save you Excel as a text file (use comma delimited). Save the text file with any name you like.

2) Type the following as an SQL query: USE MyDatabase; LOAD DATA INFILE "/mydirectory/myfolder/myfile.txt INTO TABLE MyTable FIELDS TERMINATED BY ',' ENCLOSED BY '"';

You could refine the above by specifying the fields into which you wanted the data to be imported - for example: LOAD DATA INFILE "/mydirectory/myfolder/myfile.txt INTO TABLE MyTable FIELDS TERMINATED BY ',' ENCLOSED BY '"' (Last_Name, First_name, Address, Town, Occupation);

You can also choose to REPLACE or IGNORE duplicate values by addingthe appropriate keyword infornt of the word INTO.

Hope this helps.

Jon

-----Original Message----- From: Robbert - Jan van Velzen [mailto:robb@amswp.nl] Sent: 15 November 2001 10:13 To: 'Sergio Augusto Bitencourt Petrovcic' Cc: 'win@lists.mysql.com' Subject: RE: Excel to MySQL...

The way I convert Excell files to MySQL is using PHP.

1. Save your Excell file as DBaseIV .dbf 2. I read out the dbf file using PHP's dbase functions and then insert the data into MySQL

I assume other languages also have support for dbase.

Hi there... I have an excel table with 7000 rows and I would like to put them into mysql. How could I do it? []'s