473,769 Members | 7,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("LO AD 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 8706
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**@jobmarket intelligence.co m> schrieb im Newsbeitrag
news:ktu3b.2890 81$uu5.63240@sc crnsc04...
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
2369
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 14:18:04 If I copy this page on some other(existing) virtual directory, I get as a result 22.1.2004 14:19:06
4
1305
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 can not seem to get any of the functions working on it. So I have now dopwnloaded the latest version hoping that this will fix the error. I have managed to install the MySQL-shared-compat-4.0.1-0.i386.rpm but
0
1883
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 fieldTypeCodes of 10 - 17. For any given query there will be up to 4 Extension nodes fitting this criteria. I have everything working except for being able to insert a, b, c or d in the <box12 tags. Notice each row or found node has a different letter. ...
7
2253
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 3-8266-1337-6, see <http://www.mitp.de/vmi/mitp/detail/pWert/1337>). I am the translator of this work, but let me assure you I don't get any additional money depending on how much it sells. On the other hand, the publisher has assured me that a...
1
1242
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 english versions. Because of that I installed the english version of VS.NET.
7
5239
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; hj-54-56; 1565.00; 0 8228880; 30-56-tw; 3295.50; 0 0022339; hs-sa-73; 2975,75; 0 .... etc
0
2112
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 Unicode encoding. I made and installed contrib/tsearch2 after installing the dump/reload-patch http://www.sai.msu.su/~megera/postgres/gist/tsearch/V2/regprocedure_7.4.patch.gz as advised by the docs. So far everything is looking good, I have...
0
1386
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 to an axis service on a german windows system with a german VS.net 2002 - If I have german special characters (Umlaute äöü...) in a string variable everything works fine on the german system, but if a install the client on an english system the...
20
35620
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 project the date format in vb.code ( not in Windows) and how can I find out which date format the PC Windows is using. Thanks for any response
122
4310
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
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8873
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
3965
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.