fgetcsv

Importing CSV with Asian Characters in PHP [closed]

余生长醉 提交于 2021-01-28 05:08:50
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 7 years ago . Improve this question I'm trying to import CSVs or Unicode Text with Thai Characters into MySQL. There's no problem with MySQL saving Thai Characters. The problem is, when I use fgetcsv or fgets, I get garbage in exchange for the Thai Characters. Like for example, these characters,

How to improve the speed of insertion of the csv data in a database in php?

爱⌒轻易说出口 提交于 2020-08-10 18:59:12
问题 I wrote this code that allows to read a folder, depending on the file name is inserted in a different table the data of the csv file. Once the file is processed it is moved to another folder. My code works well but the second csv file is more than 80 000 lines long and it takes several hours to be integrated in my database. How can I improve the performance of my code? I tried 'LOAD DATA LOCAL' but without success... <?php include("../connexion.php"); ini_set('max_execution_time', 54000);

fgetcsv fails to read line ending in mac formatted csv file, any better solution?

守給你的承諾、 提交于 2020-07-04 06:10:05
问题 I was parsing a csv file using php with fgetcsv function. It parsed all content in a line, later i found, csv contains carraige return as "\r". I saw - it was reported as php bug before. I've solved this by setting php runtime configuration which is - ini_set("auto_detect_line_endings", "1"); is there any more solution or is this the right way? Thanks 回答1: Setting auto_detect_line_endings is explicitly recommended by the php documentation. However, I cannot fathom why you would want to

fgetcsv fails to read line ending in mac formatted csv file, any better solution?

|▌冷眼眸甩不掉的悲伤 提交于 2020-07-04 06:10:03
问题 I was parsing a csv file using php with fgetcsv function. It parsed all content in a line, later i found, csv contains carraige return as "\r". I saw - it was reported as php bug before. I've solved this by setting php runtime configuration which is - ini_set("auto_detect_line_endings", "1"); is there any more solution or is this the right way? Thanks 回答1: Setting auto_detect_line_endings is explicitly recommended by the php documentation. However, I cannot fathom why you would want to

fgetcsv fails to read line ending in mac formatted csv file, any better solution?

六眼飞鱼酱① 提交于 2020-07-04 06:08:46
问题 I was parsing a csv file using php with fgetcsv function. It parsed all content in a line, later i found, csv contains carraige return as "\r". I saw - it was reported as php bug before. I've solved this by setting php runtime configuration which is - ini_set("auto_detect_line_endings", "1"); is there any more solution or is this the right way? Thanks 回答1: Setting auto_detect_line_endings is explicitly recommended by the php documentation. However, I cannot fathom why you would want to

Looping through a csv with fgetcsv

怎甘沉沦 提交于 2020-02-21 10:44:05
问题 I have a csv file with 3 columns: email address , first name and last name . I have got the stage where I can print out the array using the following code: <?php $file = fopen("testEmails.csv","r"); while(! feof($file)) { print_r(fgetcsv($file)); } fclose($file); ?> This prints the array, so every field in a row. What I want it to print is purely the values in the first column of the row. How would this be done, documentation on fgetcsv seems very sketchy to me (a relative beginner). Thanks.

fgetcsv() not reading Arabic characters

五迷三道 提交于 2020-02-05 02:38:12
问题 When trying to import a CSV file, Arabic characters vanish when running fgetcsv , yet when I print the output from fopen , the Arabic characters are displayed just fine. The strange thing is that this is only happening in our production environment and not in my development environment, where fgetcsv reads the Arabic characters just fine. Is there some server setting that's not set correctly in production? 回答1: fgetcsv() makes assumptions about the file's encoding based on the system locale.

PHP - fgetcsv loop for get data from csv file column by column

試著忘記壹切 提交于 2020-01-25 21:26:12
问题 I have a CSV file with 31 columns and 24 rows. I need with fgetcsv (or maybe another solution) to pass in the CSV and get data column by column. I have one solution: // { ? for ($col=1; $col<=32; $col++) { while ($data = fgetcsv($read, max, ";")) { $row[] = $data[$col]; } print_r($row); //... in the line behind i have sql query to insert data in base. } unset($row); } The for loop is working but $data[$col] only gets data from the first column of the CSV, it doesn't get data from $data[$col]

fgetcsv is not splition data properly

﹥>﹥吖頭↗ 提交于 2020-01-25 02:45:08
问题 i am importing csv file to upload data into database. But in some products the description is not going through properly. the description is like TSD/UHC Model UG-132, 6\" gas revolver with plastic shells. Shells: MUG131 & MUG131BRASS. 290-320 FPS with .20g BBS. Legal Disclaimer Restrictions: You must be 18 or older to order this product. In some areas, state and local laws further restrict or prohibit the sale and possession of this product. In ordering this product, you certify that you are

Out of memory error when reading a large file

不羁的心 提交于 2020-01-21 06:57:24
问题 I have a large csv that I want to parse and insert into my database. I have this PHP: $target = '../uploads/'.$f; $handle = fopen($target, "r"); $data = fgetcsv($handle, 0, ","); $rows = array(); while ($data !== FALSE) { $rows[] = $data; } fclose($handle); if (count($rows)) { foreach ($rows as $key => $value) { echo $value; } } Every time I try to run my script I get this error: Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes) Any ideas how to do