2012-01-04 101 views

回答

4

嘗試將','替換爲'。'加載時。

例如 -

LOAD DATA INFILE 'file.csv' INTO TABLE dados_meteo 
(@var1, @var2) 
SET column1 = REPLACE(@var1, ',', '.'), column2 = REPLACE(@var2, ',', '.') 
1

如果$場[0]是你的數字:

LOAD DATA INFILE '$filename' INTO TABLE dados_meteo IGNORE 3 LINES 
(@var1, $fields[1], $fields[2], $fields[3], $fields[4], $fields[5]) 
SET POM='$pom', $field[0] = CONVERT(REPLACE(@var1,',', ''), DECIMAL(10)); 

如果有更多的數字,只是用@ VAR2,@ VAR3等重複的圖案你要更換DECIMAL(10)無論你的領域是什麼。

+0

謝謝@Andrew我嘗試後最終代碼 - 是給我一個語法錯誤 – Hugo 2012-01-04 23:52:16

+0

'LOAD DATA INFILE '$文件名' INTO TABLE dados_meteo忽略三行 (@ SET POM ='$ pom', $ field [0] = CONVERT(REPLACE(@ var1,',',''),DECIMAL(varl,@ var2,@ var3,@ var4,@ var5,@ var6) 10)), $ field [1] = CONVERT(REPLACE(@ var2,',',''),DECIMAL(10)), $ field [2] = CONVERT(REPLACE(@ var3,',', '),DECIMAL(10)), $ field [3] = CONVERT(REPLACE(@ var4,',',''),DECIMAL(10)), $ field [4] = CONVERT(REPLACE(@ var5,',','),DECIMAL(10)), $ field [5] = CONVERT(REPLACE(@ var6,',',''), DECIMAL(10)) ;' – Hugo 2012-01-04 23:58:53

+0

你是通過PHP運行的嗎?你到底在哪裏發生了什麼錯誤? – Andrew 2012-01-05 00:16:52