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

Ask a Question related to PHP Development, Design and Development.

  1. #1

    Default 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


    Andreas Emmert Guest

  2. Similar Questions and Discussions

    1. CFMX7 Verity: editing style files
      Has any kind individual edited the style.* files successfully? I'm on CFMX7, Solaris 2.8 and the same rules as before don't seem to apply i.e....
    2. Character style has a little + after style
      Sometimes when I try to change some copy to a particular character style, the font won't fully change. Instead I get a small + after the style. How...
    3. Need help with Style conversion from Style object to Style key/value collection.
      I am writing a custom control that derives from the DataGrid control. I would like to apply SelectedItemStyles and ItemStyles for use in my derived...
    4. Page Number - style i, ii, iii
      I have successfully number a section of my document using the Roman numerals and have added a footer to print the page number, but the printed number...
    5. german version and english xtensions
      Hi I want to buy the german version of Director MX 2004. Does the german version work with english xtensions or are there problems with that?...
  3. #2

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

    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:
    [url]http://JobMarketIntelligence.com[/url]
    A database of high-tech firms at your fingertips.
    Fred Guest

  4. #3

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

    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:
    > [url]http://JobMarketIntelligence.com[/url]
    > A database of high-tech firms at your fingertips.

    Andreas Emmert Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139