title: Can pandas read messages packed with a maskint?
body: <p>The aim of my question, is to read data into a pandas data frame where the structure of each line of data is given by a flag within it.</p>
  <p>Suppose I have data in the form</p>
  <pre><code>hello~bob,~it's~7
  your~lucky~3
  day~4
  </code></pre>
  <p>There are 4 potential columns, Column A, B, C and a <a href="https://en.wikipedia.org/wiki/Mask_(computing)" rel="nofollow noreferrer">maskint</a> column dictating which columns the message on this line uses. (Maskint isn't particularly important, just some indicator which columns are included in this message.) In the above example, 4 indicates just C, 3 indicates A and B, and 7 indicates A, B and C.</p>
  <p>I want pandas to read this file of messages and use the last column to accurately fill a table. So the output I would expect would be:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">A</th>
  <th style="text-align: center;">B</th>
  <th style="text-align: center;">C</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">hello</td>
  <td style="text-align: center;">bob,</td>
  <td style="text-align: center;">it's</td>
  </tr>
  <tr>
  <td style="text-align: center;">your</td>
  <td style="text-align: center;">lucky</td>
  <td style="text-align: center;"></td>
  </tr>
  <tr>
  <td style="text-align: center;"></td>
  <td style="text-align: center;"></td>
  <td style="text-align: center;">day</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>In the case where the last column is the same for all the rows you can use pandas read_csv function once you have obtained the format. Though I don't know a way that deals with multiple lines being different.</p>
  <p>You could read it all in and convert the formatting outside of pandas then load it in but that seems really inefficient.</p>