title: how to parse a log file and load data into a database
body: <p>How can I parse a text file to extract data, including a date, and load it into my database table <code>data_table</code>?</p>
  
  <p>This is my text document <code>log.txt</code>:</p>
  
  <pre><code>127.0.0.1 1.255.255.255 - - [30/Sep/2014:23:58:33 +0200] GET http://www.google.com HTTP/1.1 200 u:123456789 ourl:http://google.com/image ac:text ssl:1
  127.0.0.1 1.255.255.255 - - [30/Sep/2014:23:58:33 +0200] GET http://www.google.com HTTP/1.1 200 u:123456789 new_data ourl:http://google.com/image ac:text ssl:1
  ...
  </code></pre>
  
  <p>these two lines are pretty similar, but in second line is the new value <code>new_data</code></p>
  
  <p>In my database table are these columns: </p>
  
  <pre><code>|IP_1|IP_2|date_time|URL|HTTP_version|port|USER_ID|new_data|OURL|ac|ssl|
  </code></pre>
  
  <p><strong>SQL code</strong>:</p>
  
  <pre><code>Load data local infile 'D:/log.txt' into table `data_table` fields terminated by ' ' lines terminated by '\n'
  </code></pre>
  
  <p>How can I parse <code>'-','-','+0200','GET'</code> from the text file? How should I fill the column <code>new_data</code> if I don't have a value in row (the best solution should be fill up with NULL )?</p>
  
  <p>I would be very thankful if you could give me some ideas. Could be PHP script as well.</p>