By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,347 Members | 1,390 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,347 IT Pros & Developers. It's quick & easy.

Number format German style => English style when importing CSV files into MySQL-DB

P: n/a
Hi there,

I'm trying to import a csv file into my MySQL database. Unfortunately the
number format for the price column is formatted in German style, i.e. XX,XX
(decimals separated by comma not by dot). When importing this file using
LOAD DATA LOCAL INFILE the decimals are cut off. I'm using column type FLOAT
for the price column in my database.

Is there any chance to preserve the decimals when importing the csv file
into my database even though the format differs from the one MySQL needs
(dot versus comma)? Is it possible to adjust the query to include this or
how can I achieve this?

My current query looks like this:

$query = mysql_query("LOAD DATA LOCAL INFILE '$file' INTO TABLE $data_table
FIELDS TERMINATED BY ';' LINES TERMINATED BY '\r\n' IGNORE 1 LINES;");

Thanks for any help!

---
Andreas
Jul 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Andreas Emmert wrote:
Hi there,

I'm trying to import a csv file into my MySQL database. Unfortunately the
number format for the price column is formatted in German style, i.e.
XX,XX (decimals separated by comma not by dot). When importing this file
using LOAD DATA LOCAL INFILE the decimals are cut off. I'm using column
type FLOAT for the price column in my database.

Is there any chance to preserve the decimals when importing the csv file
into my database even though the format differs from the one MySQL needs
(dot versus comma)? Is it possible to adjust the query to include this or
how can I achieve this?


Can't you simply write a 3 or 4-line perl script to convert the file into
the appropriate format?

-Fred

--
Shameless plug:
http://JobMarketIntelligence.com
A database of high-tech firms at your fingertips.
Jul 16 '05 #2

P: n/a
Good idea, I'll try to do this and run the file through such a filter first
before inserting everything into the database ... simple solutions are best
:)

--
Andreas

"Fred" <fr**@jobmarketintelligence.com> schrieb im Newsbeitrag
news:ktu3b.289081$uu5.63240@sccrnsc04...
Andreas Emmert wrote:
Hi there,

I'm trying to import a csv file into my MySQL database. Unfortunately the number format for the price column is formatted in German style, i.e.
XX,XX (decimals separated by comma not by dot). When importing this file
using LOAD DATA LOCAL INFILE the decimals are cut off. I'm using column
type FLOAT for the price column in my database.

Is there any chance to preserve the decimals when importing the csv file
into my database even though the format differs from the one MySQL needs
(dot versus comma)? Is it possible to adjust the query to include this or how can I achieve this?


Can't you simply write a 3 or 4-line perl script to convert the file into
the appropriate format?

-Fred

--
Shameless plug:
http://JobMarketIntelligence.com
A database of high-tech firms at your fingertips.

Jul 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.