我要转换此txt文件:
STATIONS_ID;MESS_DATUM; QN;PP_10;TT_10;TM5_10;RF_10;TD_10;eor
5371;201912250000; 2; 903.5; 2.3; 2.2; 100.0; 2.3;eor
[...]
5371;201912251820; 2; 913.3; 0.4; 0.3; 100.0; 0.4;eor
使用以下代码到mySQL数据库:
$file = fopen("produkt_zehn_now_tu_20191225_20191226_05371.txt","r");
while(!feof($file))
{
$content = fgets($file);
$carray = explode("' ', '', ;", $content);
list($station;$zeit,$quali,$luftdruck,$temp2m,$temp5cm,$feuchte,$taupunkt) = $carray;
$res_wetterdaten_dwd = $sql_datenbank -> query("INSERT INTO wetterdaten_dwd
(daten_zeit, daten_luftdruck, daten_temp2m, daten_temp5cm, daten_feuchte, daten_taupunkt, daten_station)
VALUES ('".$zeit."', ".$luftdruck.", ".$temp2m.", ".$temp5cm.", ".$feuchte.", ".$taupunkt.", ".$station.")");
}
fclose($file);
但是它不将其存储在我的数据库中。我究竟做错了什么? (最后,我实际上只想在数据库中保存最后一行(111),因为它是当前行。但是首先必须解决基本问题。)谢谢!