Welcome Guest, Not a member yet? Register   Sign In
Import CSV file - Problem...
#1

[eluser]scooby_dev[/eluser]
Hi!
I need to import datatas from csv file into a DB but i still getting errors. I found dome library in wiki but i'm getting permissions errors (permissions on server for file and directory 0777).
Maybe some of you been using that functionality in your CI and can give me some ideas how to do this properly.
I mean I just need to import all datas from CSV file and put it into a database.
Regards
#2

[eluser]gon[/eluser]
I would do this:

Code:
$content = file("/path/to/file.csv");
array_shift($content);  // skip first line if needed
foreach ($content as $line) {
      list ($id, $name, $surname, $email) = split(";", $line);
      $model->db->insert("table_name", array('id' => $id,
                                             'name' => $name,
                                             'surname' => $surname,
                                             'email' => $email);
  

}




Theme © iAndrew 2016 - Forum software by © MyBB