Import CSV, row by row, into custom table
I used the code below;

public function submitForm(array &amp;$form, FormStateInterface $form_state)
{

    $file = $form_state-&gt;getValue('csv_upload_file');

    $destination = $file[0]-&gt;toArray()['uri'][0]['value'];

    $file = fopen($destination, "r");

    while (!feof($file)) {
        $customer = fgetcsv($file);
        \Drupal::database()-&gt;insert('your_db_table')
            -&gt;fields(array(
                'column1' =&gt; $customer[0],
                'column2' =&gt; $customer[1]
            ))
            -&gt;execute();
    }

    fclose($file);

    drupal_set_message('CSV data added to the database');
}