in reply to Re: Re: From excel to mysql...
in thread From excel to mysql...

Welcome to the non M$ world ;-) The is a substantial upside to not rotating around the GUI.

Anyway with empty fields yes it *should* still work. Excel dumps empty fields as

field1\t\tfield3\tfield4

So when mysql splits on \t you get an undef (NULL) value. In that case add "default 'blah'" to the create ie:

timestamp date default '1970-01-01', joker char(32) default 'anon',

and mysql will fill in the blanks.

If your data is really dirty you may wish to parse the tab sep file with perl, check for whatever then write out all the clean data to a fresh tab sep file before you import. You could flag the errors, write them to a tab sep file and then open and fix it in Excel or just automate it.

One thing to be aware of is that you probably will want a primary key on id (so id must be not null and must also be unique). The other key/index options you will probably want is an INDEX on some/all of the other fields depending on how you plan to search it.

cheers

tachyon

Replies are listed 'Best First'.
Re: Re: Re: Re: From excel to mysql...
by disciple (Pilgrim) on Apr 13, 2004 at 18:51 UTC

    ++ great information.

    I am not a big fan of Microsoft, but it is also very easy in MS Sql Server. Data Transformation Services (included with Sql Server) can import Excel files without first saving them in another format. I can't say which is easier, that would be opinion.

Re: Re: Re: Re: From excel to mysql...
by kiat (Vicar) on Apr 13, 2004 at 15:36 UTC
    I experimented with a small set of data and so far the results are great :) I've deliberately left some fields empty in Excel. I didn't specify default values for the columns in the create statement but every value (even null values) are correctly inserted.

    cheers