I need to make 2 tables from this csv file. How can i split the file, after the second line,
This is how the csv file looks.
i've marked what i need as headers. i dont need the data from those lines.
Palle_nr;Varenummer;Ordre_nr;Operatoer;Maskin_nr
1234;1234_2019_01_14_17_11_23;1234; TN;1234
;;;;
Name;Datum;Property;Criterion;Type
1) Height 130;;avg(L)Y;;inspection_dimension_scalar
And this is how my code looks. again what i want this code to do is split the csv file after the second line. so i get a table with the Palle_nr and a table with the Name
if (isset($_POST['btn-upload'])){
copy("$sourcepath/$latest_filename","$copy/$latest_filename");
$row = 1;
if (($openfile = fopen("$copy/$latest_filename", "r")) !== FALSE) {
$csvuser->createPalleTable($latest_filename);
while ($getpdata = fgetcsv($openfile, 1000, ";")) {
$getpdata = array_map("utf8_encode", $getpdata);
$totalp = count($getpdata);
$row++;
for ($i=0; $i < $totalp; $i++) {
$pdata = implode(";", $getpdata);
$palledata = explode(";", $pdata);
}
$csvuser->insertPalleTable($latest_filename,$palledata);
}
///////// This is where i want the file to split ///////
$header = fgetcsv($openfile, 1000, ";");
$header = array_map("utf8_encode", $header);
$totalheader = count($header);
for ($i=0; $i < $totalheader; $i++) {
$headerdata = implode(";", $header);
$th = explode(";", $headerdata);
}
$csvuser->createCsvTable($latest_filename);
while ($getdata = fgetcsv($openfile, 1000, ";")) {
$getdata = array_map("utf8_encode", $getdata);
$total = count($getdata);
$row++;
for ($c=0; $c < $total; $c++) {
$csvdata = implode(";", $getdata);
$fncsvdata = explode(";", $csvdata);
}
$csvuser->insertCsvTable($latest_filename,$fncsvdata);
}
}
}
If you need the whole code so you can recreate the problem. then ill upload it but thought it would be to much code.
Other ways of reading the file is also appreciated. i just need to be able to split the file.