jmbarra78
Member
Hi,
I need a cron task that import csv files every 5 minutes, without headers. ImportCSV plugin needs headers in csv files, so I would like develop my custom code. My first problem is csv file is not found... This is my piece of code:
I get "File not found..."My project is in http://www.mydomain.com/proyecto
what's wrong in CSV path?
If I use code below instead of "if (!file_exists($csv_file))..."
...I get NULL with var_dump($datos)...
I need a cron task that import csv files every 5 minutes, without headers. ImportCSV plugin needs headers in csv files, so I would like develop my custom code. My first problem is csv file is not found... This is my piece of code:
PHP:
defined('_JEXEC') or die();
// Get a db connection.
$db = FabrikWorker::getDbo();
//import csv file
define('CSV_PATH','../proyecto/media/csv/cliente1/finca1/invernadero1/');
$csv_file = CSV_PATH . "data.csv"; // Name of your CSV file
if (!file_exists($csv_file)) {
echo "File not found. Make sure you specified the correct path.\n";
exit;
}
what's wrong in CSV path?
If I use code below instead of "if (!file_exists($csv_file))..."
PHP:
$csvfile = fopen($csv_file, 'r') || die("File not found");
$datos = fgetcsv($csvfile, 1000, ",");