Ask the Expert

Load data problems with MySQL

I'm having problems loading data to MySQL table using LOAD DATA INFILE. How can I load a table column that should be numeric (float(4,2)) from a text fle containing a product price expressed as 1,243.56 (i.e. using a comma), without manipulating the data file prior to the load? Current process issues warnings and truncates the data.

    Requires Free Membership to View

If your data file is comma-separated there may not be much you can do, as MySQL will simply interpret the commas in your numbers as field separators unless they are escaped.

In this case you are probably best off stripping the commas in pre-processing. If your source data file was fixed-width you could also perform a LOAD DATA without specifying column separators and MySQL would read the fixed-width file.

This was first published in June 2005

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: