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
1 answer

Issue with fgetcsv causing loop in CLI but not apache2

I'm a bit stuck with the following code which correctly opens a csv file (list.csv) and detects whether there is a match in one of the lines that matches what is in the variable $match. Just to clarify, the script works correctly. When I call the…
omega1
  • 1,031
  • 4
  • 21
  • 41
0
votes
1 answer

fgetcsv is skipping lines

I have google contact file in CSV which I exported from google contacts - it's format has dividing each line with delimiter like this First Name,Middle Name,Last Name,Title,Suffix,Initials,Web…
Muhammad
  • 921
  • 2
  • 11
  • 29
0
votes
1 answer

how to prevent php fgetcsv skipping first row

I have this function that reads csv file line by line and looks for specific label in the first column of each row and then if label was found it reads all the columns next to this found label into array until column value is empty. It used to work…
anonymous007
  • 319
  • 1
  • 3
  • 12
0
votes
2 answers

Import CSV File With Field Including Commas In Quotes?

I am importing the following data from a CSV file, whose formatting I have absolutely no control over: CampaignName,"""keyword""",441,11683,3.77%,2.99,112.82,"1,318.02",1.7,12,109.84 As you can see, one of the fields has a long number with a comma…
FarhadD
  • 485
  • 5
  • 14
0
votes
1 answer

How to remove double quotes stored in the database while reading through fgetcsv

This is my code. Whenever I execute this, data stores in the database in double quote as a "park avenue". if ($_FILES["csv_file"]["size"] > 0) { //get the csv file $file = $_FILES["csv_file"]["tmp_name"]; $handle = fopen($file,"r"); …
0
votes
0 answers

Selective parsing of CSV file in HTML

I have VB program which generates a CSV file and updates it every second. I've used a CSV to HTML parser to display the CSV data in a table in an HTML page. The problem I'm facing is, I want only selective data from the CSV to be displayed…
Vishwas Pawar
  • 183
  • 2
  • 16
0
votes
0 answers

PHP fgetcsv, loops and arrays

I have created this script based off of a youtube tutorial:
Leo Ashcraft
  • 35
  • 1
  • 9
0
votes
1 answer

PHP fgetcsv transpose 2 dimensional array

CSV data needs to be converted to key 2 dimensional array ------------ file = csvdata.csv -------- symbol,date1,date2,date3,date4 QCOM,10,11,12,13 CTSH,20,21,22,23 AAPL,41,42,43,44 ------------ end of csv file ---- $inputsymbol = QCOM ; //…
0
votes
1 answer

PHP fgetcsv 2 dimensional array

I have seen few similar examples but it is still not working. csv data file "data1.csv" is as…
0
votes
1 answer

sum row data in csv file using php

I am trying to sum a single row of data(numbers) from a csv file to display the total number using php. this is the csv file I have: A 0.01 0.1 0.02 0.01 0.02 0.01 0.02 Basically it stretches on. A is basically the first row alphabet in…
0
votes
3 answers

PHP how to return false with file() for an empty .csv file?

Why do I always get a array with one item of empty string for an empty .csv file? $content = file('products.csv'); print_r($content); result: Array ( [0] => ) Can I return false so that I know there is nothing in the csv file?
Run
  • 54,938
  • 169
  • 450
  • 748
0
votes
1 answer

Parse a CSV file extracting some of the values but not all

Good day, I have a local csv file with values that change daily called DailyValues.csv I need to extract the value field of category2 and category4. Then combine, sort and remove duplicates (if any) from the extracted values. Then save it to a new…
Yallaa
  • 63
  • 1
  • 8
0
votes
1 answer

fgetcsv fails on a specific line

My code works fine excepts for one line. It was working without any problem since one year but now there is one line in the file making my code buggy. The…
zeflex
  • 1,487
  • 1
  • 14
  • 29
0
votes
0 answers

Parsing a large CSV in PHP

I have a large CSV I am writing a PHP CLI script to import into an existing PHP application, while utilizing the existing application's ORM to do relationship management between fields (trust me, I looked at a SQL CSV import, its easier this way).…
Cameron Kilgore
  • 383
  • 7
  • 25
0
votes
1 answer

Read and write using fgetcsv and fputcsv

I have a 3rd party source from where I am getting "csv" file. I wrote it inside a quote because it says it's a csv file but basically it's not. So I am taking that main source file then reading and putting the data in a "PROPER" csv file. The read…
Raj
  • 1,377
  • 6
  • 23
  • 48