Questions tagged [fgetcsv]

fgetcsv() is a PHP function which parses the line it reads for fields in CSV format and returns an array containing the fields read.

491 questions
-1
votes
1 answer

fgetcsv ignores csv from website but not local

i am writing a script to reach out to a website that downloads a csv into cache and then parses the data into an array. $base_url =…
-1
votes
1 answer

fgetcsv inserting charactor like ?????? into mysql database

I am making a little php application with fgetcsv for inserting multiple record into mysql database. It works fine with english charactor. But when I trying to add foreign language like bengali or hindi it inserts ????? into mysql database. Here my…
S.k.joy
  • 51
  • 4
-1
votes
1 answer

Importing large size of CSV to SQL got this Warning: fopen(): Filename cannot be empty

I tried to import multiple rows of CSV to SQL and this code is working with few number of rows only (ex. 75 rows) to import and it succeed but when I tried to import multiple number of rows (ex. 700000 rows) in SQL this appears. if(($handle =…
Zach
  • 53
  • 2
  • 11
-1
votes
2 answers

can't complete on fgetcsv in mysql

connect_error) { …
RileyTse
  • 1
  • 5
-1
votes
2 answers

php read csv data as a string

Is there a function in php that lets you read a csv and return a string as it is. I am aware of functions like fgetcsv etc that reads the csv and returns an array. But I was wondering if there is a way to get the full string as it is.
Kiran Dash
  • 4,816
  • 12
  • 53
  • 84
-1
votes
1 answer

How to join two different array values and create csv file in php

Here is my task $value1= ['apple', 'ball', 'cat', 'dog']; $value2= ['elephant', 'frog', 'griffee', 'honeybee']; $value3 = [1,3,4,5]; I want to create a csv file by combining this two different array. $fp = fopen('sample.csv', 'w'); foreach (…
jvk
  • 2,133
  • 3
  • 19
  • 28
-1
votes
1 answer

PHP CSV import getting strange charators

I'm trying to import a product csv using PHP to MySQL. When i try to import I got strange characters which also not add properly to database table. Product Name on CSV File Alva Cook'on Braadpan Lavendelblauw ovaal 24 cm – 4,2 Liter Product name i…
Suneth Kalhara
  • 1,116
  • 4
  • 16
  • 40
-1
votes
1 answer

How to update specific column using fgetcsv

I'm trying to update a specific column through fgetcsv. But the problem is all the data are the same. Can someone help me about this? I don't know how to make the use of grade_id here because there are no grade_id in csv only in the database. And im…
nethken
  • 1,072
  • 7
  • 24
  • 40
-1
votes
1 answer

PHP looping through file internal error without logs

I use AJAX to get some JSON data from a file on my server. Server-side code $file = fopen($path); /*~1M rows and ~650MB file*/ /*Headers*/ $cols = fgetcsv($file); $cols[0] = 'id'; /*Loop through each line*/ $file_arr = []; while (($line…
Wistar
  • 3,770
  • 4
  • 45
  • 70
-1
votes
1 answer

PHP script for adding prefix to sku when duplicate in .csv

At the moment I have a script that will remove the row in my csv when it has already seen the sku before. Here is the script:
Mike Tim Turner
  • 123
  • 2
  • 8
-1
votes
1 answer

Supressing fgetcsv warning

I have the following function to get a csv file form a third party resource: public function getSubject() { $file = fopen( $this->url , 'r'); $result = array(); while ( ( $line = fgetcsv( $file )) !== false…
HappyCoder
  • 5,985
  • 6
  • 42
  • 73
-1
votes
1 answer

PHP fgetcsv display specific columns only

I'm using the code below (from a previous post) to pull from an csv file but I'd like to just display specific columns. I've already tried to modify using other solutions with no avail. Any help would be much appriciated.
phpn00b
  • 3
  • 5
-1
votes
1 answer

How to access array in outside while loop in fgetcsv

I want to fetch all the contents of a csv file into an array so I used the fgetcsv function. It is working correctly, but when I want to return my array it is empty. The problem seems to be outside the while loop. Here is my…
snehal
  • 429
  • 5
  • 11
  • 25
-1
votes
2 answers

Returning selected rows from a csv

I'm using php(fgetcsv) in order to parse a csv file. The file is continuously updated and quite large. Is it possible to only return a selected number of rows(say the first 10 rows for example)?
Jason
  • 195
  • 1
  • 3
  • 15
-2
votes
1 answer

PHP fopen or file_get_contents reading CSV files with fgetcsv

I have a issue. In my original code I opened a file with: $file = fopen ("files/bla1.exp" , "r" ); And after opening the file, I want to read the CSV line by line with: $aCsvLine = fgetcsv($file,"0",";",'"'); That works fine, but now the problem.…
1 2 3
32
33