Pe 27 Sep 2006, la 10:29, Chris <[EMAIL PROTECTED]> a scris:
> >[EMAIL PROTECTED] wrote: >> hi, everyone! >> I have a text file like this: >> 10:10:00 0 0 1 99 >> 10:20:00 0 0 1 99 >> 10:40:00 11 3 4 83 >> 11:00:00 1 1 2 97 >> 11:05:00 2 1 1 96 >> >> I need to load this file into a table, but I cannot figure out the syntax of >> LOAD DATA INFILE command. As you can see, the fields are separated by a >> variable number of blank spaces (not tabs). How can I do this? > >Did you try using a space (' ') as the separator? Did you get an error? Yes, I did. load data infile '/home/kido/data.txt' into table test fields enclosed by ' '(server_time,usr,sys,wio,idle); the result was that first field (e.g. 10:10:00) was populated correctly, while the others fileds were populated with NULL values. mysql> select * from test; +-----+-------------+------+------+------+------+ | id | server_time | usr | sys | wio | idle | +-----+-------------+------+------+------+------+ | 399 | 06:05:00 | NULL | NULL | NULL | NULL | | 400 | 06:06:00 | NULL | NULL | NULL | NULL | I also tried: load data infile '/home/kido/data.txt' into table test fields terminated by ' '(server_time,usr,sys,wio,idle); and the corresponding fileds were populated with 0 (zerros): | 505 | 11:10:00 | 0 | 0 | 0 | 0 | | 506 | 11:20:00 | 0 | 0 | 0 | 0 | | 507 | 11:40:00 | 0 | 0 | 0 | 0 | | 508 | 12:00:00 | 0 | 0 | 0 | 0 | So, I need to specify somehow that the fields are delimited by any number of spaces... -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]