MySQL中游标使用以及读取文本数据(二)

2015-02-02 13:37:26 · 作者: · 浏览: 47
10),
get_time
datetime,
PM25
int,
PM10
int,
NO2
int,
temperature
int,
pressure
int,
humidity
int,
wind
double,
weather
int);

load data local
infile
'f:\\dataset\\beijing\\crawleddata.txt'
into table traindata
fields terminated
by ','
(station_id,
@var_time, PM25, PM10, NO2, temperature, pressure, humidity, wind, weather)
set get_time = str_to_date(@var_time, '%c/%e/%Y %l:%i:%s %p');

select * from traindata limit 10;


加载进数据库后,具体数据格式如下:


+----+------------+---------------------+------+------+------+-------------+----------+----------+------+---------+
| id | station_id | get_time? ? ? ? ? ? | PM25 | PM10 | NO2? | temperature | pressure | humidity | wind | weather |
+----+------------+---------------------+------+------+------+-------------+----------+----------+------+---------+
|? 1 |? ? ? 1001 | 2013-02-08 21:00:00 |? 149 |? 59 |? 16 |? ? ? ? ? -5 |? ? 1031 |? ? ? 46 |? ? 4 |? ? ? 1 |
|? 2 |? ? ? 1001 | 2013-02-08 22:00:00 |? 159 |? 65 |? 22 |? ? ? ? ? -5 |? ? 1030 |? ? ? 46 |? ? 1 |? ? ? 1 |
|? 3 |? ? ? 1001 | 2013-02-09 00:00:00 |? 179 |? 73 |? 28 |? ? ? ? ? -6 |? ? 1029 |? ? ? 46 |? ? 4 |? ? ? 1 |
|? 4 |? ? ? 1001 | 2013-02-09 02:00:00 |? 194 |? 73 |? 29 |? ? ? ? ? -7 |? ? 1028 |? ? ? 49 |? ? 3 |? ? ? 1 |
|? 5 |? ? ? 1001 | 2013-02-09 03:00:00 |? 191 |? 73 |? 27 |? ? ? ? ? -7 |? ? 1028 |? ? ? 50 |? ? 2 |? ? ? 1 |
|? 6 |? ? ? 1001 | 2013-02-09 04:00:00 |? 194 |? 73 |? 25 |? ? ? ? ? -7 |? ? 1026 |? ? ? 53 |? ? 2 |? ? ? 1 |
|? 7 |? ? ? 1001 | 2013-02-09 05:00:00 |? 193 |? 73 |? 23 |? ? ? ? ? -7 |? ? 1026 |? ? ? 54 |? ? 2 |? ? ? 1 |
|? 8 |? ? ? 1001 | 2013-02-09 06:00:00 |? 192 |? 73 |? 21 |? ? ? ? ? -8 |? ? 1026 |? ? ? 52 |? ? 2 |? ? ? 1 |
|? 9 |? ? ? 1001 | 2013-02-09 07:00:00 |? 192 |? 73 |? 23 |? ? ? ? ? -8 |? ? 1025 |? ? ? 54 |? ? 3 |? ? ? 1 |
| 10 |? ? ? 1001 | 2013-02-09 08:00:00 |? 190 |? 73 |? 20 |? ? ? ? ? -8 |? ? 1025 |? ? ? 55 |? ? 3 |? ? ? 1 |
+----+------------+---------------------+------+------+------+-------------+----------+----------+------+---------+


see,标准的数据格式。


--------------------------------------分割线 --------------------------------------


--------------------------------------分割线 --------------------------------------