How to read txt lines and insert into Database with PHP

1

I need to get the value of each row and each column to insert into the database, but there are results that the Remarks field is in two lines and is actually the continuation of the previous row. I am not able to put it in the continuation of the previous line.

TXT Link

The result I need is this:

<table>
<thead>
   <tr>
       <th>IDENT ANV</th>
       <th>TIPO</th>
       <th>ADEP</th>
       <th>EOBT</th>
       <th>VEL</th>
       <th>FL</th>
       <th>ROTA</th>
       <th>DEST</th>
       <th>EET</th>
       <th>OBS</th>
    </tr>
    </thead>
    <tbody>
    <tr>
       <td>AZU2400</td>
       <td>E190</td>
       <td>SBGR</td>
       <td>11:25</td>
       <td>N396</td>
       <td>290</td>
       <td>DCT DORLU UZ37 VUREP DCT</td>
       <td>SBRJ</td>
       <td>00:40</td>
       <td>EQPT/SDFGHIRWY PBN/A1B1D1O1S2</td>
    </tr>
    </tbody>
</table>
    
asked by anonymous 03.04.2017 / 18:25

1 answer

0

Your data source is very erratic.

Firstly, it is not using line break delimiters (\ n \ r), which makes standard reading impossible, the text is all indented by spaces, and since the field observations sometimes appears randomly with 10 or 6 digits, it is very difficult to extract the data.

What I recommend is you first standardize the data source and then do the necessary work.

In the case the closest regular expression I got was:

/ \ d {6}. + (\ w {3,4} / \ w {8,10}) {1,4} / g

But I reiterate that without breaking lines and without standardization, the regular expression will not serve.

To test use link

    
03.04.2017 / 19:22