1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
| $row_count_limit = 60000;
$file_counter = 1;
$file_name = 'C:\\projets\\ticket_rawsrc\\csv\\testicket\\testdecoupage\\Trends_INC_Données_complètes_data septembre.';
$file_ext = 'csv';
$row = 1;
$ctr = 0;
$cols = array();
DispMsg::DispMsg("PHP CSV Chunker\n\n",true);
//echo "PHP CSV Chunker\n\n";
DispMsg::dispMsgWithoutMenu("Ouverture du fichier source -> ".$file_name .
$file_ext .
"\n",true);
if (
($handle_src = fopen("$file_name" .
"csv",
"r")) !==
FALSE
)
{
$cols = fgetcsv($handle_src,
1000,
";");
if (
($handle_dest = fopen("$file_name" .
$file_counter .".".
$file_ext,
"a+")) !==
FALSE
)
{
fputcsv($handle_dest,
$cols);
while (($data = fgetcsv($handle_src,
4096,
";")) !==
FALSE)
{
$num = count($data);
fputcsv($handle_dest,
$data);
$row++;
if (
$row ==
$row_count_limit
)
{
fclose($handle_dest);
$row = 1;
DispMsg::DispMsg("\t Création du fichier --> " .
$file_name .
$file_counter .
$file_ext .
"\n",true);
$handle_dest = fopen("./$file_name" .
$file_counter .".".
$file_ext,
"a+");
$file_counter++;
fputcsv($handle_dest,
$cols);
}
}
fclose($handle_src);
}
}
else
{
}
DispMsg::dispMsgWithoutMenu("Fin du programme \n",true); |
Partager