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

Posted: 08-28-2003, 08:35 PM
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


Reply With Quote

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

Fred
Guest
Posts: n/a
 
Re: Number format German style => English style when importing CSV files into MySQL-DB
Posted: 08-28-2003, 09:27 PM
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.
Reply With Quote
Andreas Emmert
Guest
Posts: n/a
 
Re: Number format German style => English style when importing CSV files into MySQL-DB
Posted: 08-29-2003, 05:56 AM
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" <fred@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.

Reply With Quote
 
LinkBack Thread Tools Search this Thread Display Modes
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
mx:Style rajeshj Macromedia Flex General Discussion 0 04-21-2005 10:20 PM
CSS Link Style Silwolffe Dreamweaver AppDev 3 04-15-2005 02:57 AM
Need help with Style conversion from Style object to Style key/value collection. Ken Varn ASP.NET Building Controls 0 04-26-2004 07:06 PM
Page Number - style i, ii, iii Karen_A._Tillery@adobeforums.com Adobe Acrobat Windows 4 04-08-2004 08:25 PM
Looking for a style ... Arthur Way Macromedia Fireworks 5 07-25-2003 09:47 PM