title: Parsing a CSV file into multiple SQL tables. Pivoting column names to row variables with a new id
body: <p>I have multiple CVS files that I need to add into my database. I want to add the CVS data into multiple SQL tables and also take the column names and parse as variables in the same column and give them separate ids.</p>
  <p>The CVS files have similar setup:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>CustomerID</th>
  <th>apple</th>
  <th>orange</th>
  <th>banana</th>
  <th>mango</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>30</td>
  <td>4</td>
  <td>2</td>
  <td>7</td>
  </tr>
  <tr>
  <td>2</td>
  <td>5</td>
  <td>6</td>
  <td>8.</td>
  <td>9.</td>
  </tr>
  <tr>
  <td>3</td>
  <td>7</td>
  <td>2</td>
  <td>3</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>and get the following tables:</p>
  <p>Fruits</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>Fruit_name</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>apple</td>
  </tr>
  <tr>
  <td>2</td>
  <td>orange.</td>
  </tr>
  <tr>
  <td>3</td>
  <td>banana.</td>
  </tr>
  <tr>
  <td>4</td>
  <td>mango</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Receipt</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID.</th>
  <th>CustomerID</th>
  <th>FruitID</th>
  <th>Amount</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>1.</td>
  <td>1.</td>
  <td>30.</td>
  </tr>
  <tr>
  <td>2</td>
  <td>1.</td>
  <td>2.</td>
  <td>4.</td>
  </tr>
  <tr>
  <td>3</td>
  <td>1.</td>
  <td>3.</td>
  <td>2.</td>
  </tr>
  <tr>
  <td>4</td>
  <td>1.</td>
  <td>4.</td>
  <td>7</td>
  </tr>
  <tr>
  <td>5</td>
  <td>2.</td>
  <td>1</td>
  <td>5.</td>
  </tr>
  <tr>
  <td>6</td>
  <td>2.</td>
  <td>2.</td>
  <td>6.</td>
  </tr>
  <tr>
  <td>7</td>
  <td>2.</td>
  <td>3.</td>
  <td>8.</td>
  </tr>
  <tr>
  <td>8</td>
  <td>2.</td>
  <td>4.</td>
  <td>9.</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>etc.</p>
  <p>I don't know where to start. If I should add the csv files to sql temp table and then seperate or iterate directly into the tables in the database.</p>
  <p>I'm probably complicating the thought process in my head so all ideas are helpful.</p>