I use WinSCP to continuously retrieve CSV files from a remote FTP
I created a PHP script that scans folder every 10 minutes in order to import these CSV files into a database using a LOAD DATA INFILE
The problem is that my PHP script does LOAD DATA INFILE
even if the file is still being downloaded by WinSCP (some files are 1 to 2gb, so sometimes it takes a long time)
So I would like to add a condition before the LOAD DATA INFILE
to check if the CSV file is locked for modification by another user (this is what Excel tells me when I try to open it manually)
I tried several things:
is_file($file_path)
boolean true
is_writable($file_path)
boolean true
is_readable($file_path)
boolean true
file_exists($file_path)
boolean true
When I use a fopen it gives me a false
return
fopen($file_path, "r+")
boolean false
But I have an exception and I don't know if opening 2gb files before each LOAD DATA INFILE
will not lower the performance of the script
Warning: fopen(***\booking.csv): failed to open stream: Resource temporarily unavailable in ***\load.php on line 62