相关疑难解决方法(0)

PHP script to import csv data into mysql

I have tried the following code but getting some errors. Here I can read the input file but I am getting the following error:Deprecated: Function split() is deprecated in C:\wamp\www\aaj2\index.php on line 63. O/P: Found a total of 5124 records in this csv file.

<?php
$databasehost = "localhost"; 
$databasename = "test"; 
$databasetable = "sample"; 
$databaseusername="test"; 
$databasepassword = ""; 
$fieldseparator = ","; 
$lineseparator = "\n";
$csvfile = "filename.csv";
$addauto = 0;
$save = 1; 
$outputfile = "output.sql";        

        if(!file_exists($csvfile)) {    echo "File …
Run Code Online (Sandbox Code Playgroud)

php mysql csv

15
推荐指数
2
解决办法
9万
查看次数

从php中的csv文件中读取大数据

我正在阅读csv并使用mysql检查记录是否存在于我的表中或不存在于php中.

csv有大约25000条记录,当我运行我的代码时,它显示"服务不可用"错误2m 10s后(onload:2m 10s)

这里我添加了代码

// for set memory limit & execution time
ini_set('memory_limit', '512M');
ini_set('max_execution_time', '180');

//function to read csv file
function readCSV($csvFile)
{
    $file_handle = fopen($csvFile, 'r');
    while (!feof($file_handle) ) {

       set_time_limit(60); // you can enable this if you have lot of data

       $line_of_text[] = fgetcsv($file_handle, 1024);
   }
   fclose($file_handle);
   return $line_of_text;
 }

// Set path to CSV file
$csvFile = 'my_records.csv';

$csv = readCSV($csvFile);

for($i=1;$i<count($csv);$i++)
{
   $user_email= $csv[$i][1];

   $qry = "SELECT u.user_id, u.user_email_id FROM tbl_user as u WHERE …
Run Code Online (Sandbox Code Playgroud)

php csv large-data

7
推荐指数
2
解决办法
4万
查看次数

标签 统计

csv ×2

php ×2

large-data ×1

mysql ×1