At 20:55 -0700 7/6/04, John Mistler wrote:
For some reason, the imported information showed up as garbled nonsense.
The file I was importing was an .xls file.  Do you know if there is another
"TERMINATED BY" I should be using?  If not, I wonder how I can find out?

LOAD DATA will not, I think, read Excel spreadsheets that are in native format. You'll need to extract the data in some form that LOAD DATA can use. There are modules available for this task for various programming languages. There is one for Perl, for example. (If you get the recipes distribution from http://www.kitebird.com/mysql-cookbook/ and look in the transfer directory, you'll find a from_excel.pl script that you can use to yank out the data in tab-delimited format.)


The other question I have is: do I have to create a table within the MySQL database with exactly the right number of columns ahead of time for the import to work? - this is what I did. If so, is there a way to import info from a .dbf or .xls file without knowing the structure of the table ahead of time?

The aforementioned recipes distribution has a guesstable.pl script (also in the transfer directory) that might be useful for this. It requires input in tab-delimited format, reads the information, and displays a CREATE TABLE statement that fits the data.



Thanks,

John

on 7/6/04 3:59 PM, Chinchilla Zúñiga, Guillermo at [EMAIL PROTECTED]
wrote:

 Try, for example:

 LOAD DATA INFILE 'myfile.cdf' INTO TABLE mytable
 FIELDS TERMINATED BY ',' ENCLOSED BY '"'
 LINES TERMINATED BY '\n';


-----Mensaje original----- De: John Mistler [mailto:[EMAIL PROTECTED] Enviado el: Martes, 06 de Julio de 2004 04:51 p.m. Para: [EMAIL PROTECTED] Asunto: DBF to MySQL

 I am wanting to parse the info in a .dbf file (or .xls file for that matter)
 and place it in a table in a MySQL database.  Is this something that I can
 do with the server side MySQL application, or do I need to figure out a way
 to do it on the client side?  Any description of the method would be very
 welcome!

 For what it is worth, I am a Mac OSX.3 user.

 Thanks,

 John



--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]


--
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to