473,324 Members | 2,239 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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

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
2 8664
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: simon | last post by:
I have virtual directory where I run test.asp page with only this code inside: <%Response.Write now()%> As a result, if I go into the IE and browse for the test.asp page, I get : 1/22/2004...
4
by: mikey | last post by:
Hi all, I'm having great problems trying to install the latest MySQl RPM package onto my Red Hat Linux OS. There is already MySQL v 3.0 pre-installed with the RH Linux distribution disk but I...
0
by: johkar | last post by:
My XML and XSL is below. Also below is a textual representation of what I want to get out of the XML with XSL. For each Extension node in XML, I am only concerned with those nodes with...
7
by: Peter Eisentraut | last post by:
Greetings. The official PostgreSQL documentation has been translated to German and has been published as a book by verlag moderne industrie/mitp ("PostgreSQL: Das offizielle Handbuch", ISBN...
1
by: Eric | last post by:
Hi, Normally I'm developing evertime with the english versions of Win, VS.NET, ..NET etc. But know I have a german Win XP SP1 with IIS 5.1 installed. Anyway I would like to develop with...
7
by: Sick | last post by:
My application populates a ListBox from a .TXT file. In the textfile there are prices with both dots as well as comma's for decimal indication. Example: 1234990; xg-tr-45; 1700,50; 0 2662666;...
0
by: Markus Wollny | last post by:
Hi! Sorry to bother you, but I just don't know how to get tsearch2 configured correctly for my setup. I've got a 7.4.3 database-cluster initdb'ed with de_DE@euro as locale, the database is with...
0
by: news.online.de | last post by:
Hello everybody, probably it's a FAQ but I didn't find anything so far concerning my problem, so I am asking here :-) I am facing the following problem: - I have developed a webservice client...
20
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the...
122
by: ivan | last post by:
hi all, if I have: if(A && B || C) which operation gets executed first? If I remeber well should be &&, am I correct? thanks
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.