Hi,
I was wondering if someone could help me understand how to insert a csv file in a database. Im really just having trouble with inserting it into a table. Below is what I have so far.
<?php
// File location (URL or server path)
$FilePath = "SampleFile.csv";
// Stores the content of the file
$Lines = file($FilePath);
// Counts the number of lines
$LineCount = count($Lines);
// This will be a two dimensional array that holds the content nicely organized
$Data = array();
// We will use this as an index
$i = 0;
// Loop through each line
foreach($Lines as $Value)
{
// In the array store this line with values delimited by \t (tab) as separate array values
$Data[$i] = explode(",", $Value);
// Increase the line index
$i++;
}
?>
Would i have to just take my loop and throw that in my query. For Example, Insert into Table VALUES (foreach($Lines as $Value){$Data[....
Thanks For the help.