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
0
votes
0 answers

Parsing tab delimited txt file PHP fgetcsv hangs / not ending / exiting function

This function is pretty generic its intended to parse a txt file that is delimited with a tab, the files im trying to parse is geonames database, it tops out at 1953146 results every time and from which point nothing happens at all, no more querys…
dom
  • 254
  • 1
  • 4
  • 18
0
votes
1 answer

fail to read csv file with quotations using fgetcsv()

I have a csv file that contains double quotes. when I read it using php fgetcsv(), the fields contain quotation will retrun null: while(($data=fgetcsv($handle,5000,'|'))!==false){ echo $data[0]; } and the csv file may look like this 25" H x 8"…
CharlesDou
  • 347
  • 1
  • 7
  • 16
0
votes
1 answer

CSV - not uploading all records

I'm trying to parse a small CSV file and insert the records into MySQL. The problem I'm having is that the CSV has 150 rows, but only 2 seem to be inserted: $file = new SplFileObject($uploadedFile); $separator = ','; …
user789122
  • 480
  • 5
  • 12
  • 25
0
votes
1 answer

fgetcsv not reading columns which has special characters in PHP

I am unable to get the column value which contains some special characters. I have checked many answers but i got no idea. I have pasted my sample code and data here, $pHandle = fopen($filename, "r"); while (($data = fgetcsv($pHandle, 1600, ","))…
Manigandan Arjunan
  • 2,260
  • 1
  • 25
  • 42
0
votes
1 answer

Importing large CSV files

I'm looking at importing a CSV file, but this file is rather large. What I'm looking to do, is 2 things: 1) Scan the CSV to validate values in particular fields 2) Once the file is valid, import The CSV data can ONLY be inserted if the file is…
sipher_z
  • 1,221
  • 7
  • 25
  • 48
0
votes
3 answers

How Can I make this csv reading php code more efficient

OK, so I have the following code that reads a csv file that than outputs the result in the form of a HTML table: $fhdrop = fopen("ac.csv", "r"); while (!feof($fhdrop) ) { $at[] = fgetcsv($fhdrop, 1024); } $fhdrop2 = fopen("rc.csv", "r"); while…
clickonMe
  • 521
  • 2
  • 6
  • 12
0
votes
1 answer

Check number of columns in uploaded excel-file

I'm creating a web page in which you have to upload a excel-file (either csv, xls or xlsx). Then I have to check the number of columns in the file, because the can must only contain TWO columns. I already find how to do this, but only for a…
Fingashpitzzz
  • 169
  • 4
  • 20
0
votes
1 answer

PHP to remove last line of CSV file

still struggling with PHP and CSV file manipulation. I will try to ask this properly so I can get some help. I have a CSV file with about 4000 lines/rows, and I wrote this code to create an array of the entire CSV, and pull the the LAST line of the…
user2921896
0
votes
1 answer

php fgetcsv() line ending with a comma delimiter

I am current writing a script in php that read a .csv file and push every entry to the database. The .csv file has rows that ends with ',' a,b,c,d,e,v,f, r,t,y,u,i,o,e, when i use fgetcsv($handle, 1000, ",") to read the row, the entire content of…
Roshan
  • 521
  • 4
  • 16
0
votes
1 answer

Parsing CSV file in PHP - Function returning undefined variable

I am trying to retrieve certain elements from a csv file to insert into our client reporting database. I'm trying to write a function that will parse the data and return the necessary information. However, my function is returning an undefined…
soulglow1985
  • 141
  • 1
  • 10
0
votes
2 answers

How to perform mathematical operation on data from CSV File?

I've csv file with 125 columns Indicative 125 columns are : ROLL_NO, SCHOOL_ID, NAME, STANDARD, SOURCE_ID, Q1,Q2,Q3 (this continues upto) Q120 CSV file is having around 20,0000 records (For various Schools) I want to calculate perform some…
Pawan Mude
  • 1,609
  • 6
  • 19
  • 32
0
votes
1 answer

fgetcsv dynamic length issue

This is my code and here i have given 3000 limit of characters for character limit. this is i am using to fetch data from csv file. $handle = fopen('path/to/csv/file.csv', 'r'); if ($handle) { while (($line = fgetcsv($handle, 3000, ";")) != false)…
Anil Kumar
  • 701
  • 11
  • 28
0
votes
0 answers

Parsing CSV strings to multiple-dimensional array

I'm getting the following data and I need to be able to use PHP to put this data into a multi-dimensional array so that I can use the data as variables later…
0
votes
1 answer

fgetcsv lines with extra delimiter enclosed in double quotes

I have this page in which a user uploads a CSV and then using PHP an existing MySQL table is truncated and the values from CSV are added to the table. Until now I used phpMyAdmin through Import CSV method, but I want to provide the user with a page…
Roberto C
  • 301
  • 5
  • 16
0
votes
2 answers

Covert comma delimited string to array like a csv string without using str_getcsv function

this could have been asked over and over again but i have failed to get the best answer allover google. Please help me. Problem Am fetching data from a forex rates rest API and this is exactly how the reply looks when i print it…
Hillary Namanya
  • 93
  • 4
  • 13