fgetcsv() is a PHP function which parses the line it reads for fields in CSV format and returns an array containing the fields read.
Questions tagged [fgetcsv]
491 questions
0
votes
1 answer
Regular expression in PHP fgetcsv
I have a cycle in my code where I want to extract only the first, fifth and sixth number from an array that looks like this:
Array ( [0] => 12403;644;20;46;5;285;;;; )
I am currently trying to use regular expressions to extract those numbers (in…

jvitasek
- 810
- 8
- 16
0
votes
0 answers
Why fgetcsv adds some characters between characters?
I use a php script with fgetcsv() to import data from csv files I did not create (no choice).
My problem is the data are imported to my database with a special character between each character, on each field...
For example, "Mounted print" is…

Matthieu Marcé
- 172
- 14
0
votes
1 answer
PHP use the fputcsv CSV to write same data in column for each row
I am trying to put a new data "exemple" for each line of the CSV. The lines of the csv varies. The header column name would be ExempleRow
There is not separator only a delimiter which is the semi colon.
I'm using fputcsv, it must have an array to…

Mickael B
- 13
- 1
- 3
0
votes
1 answer
PHP How to increment only 4 rows of CSV file
I am trying, to display some data from a CSV file, and need to show only the 4 first rows. Each row is inside an 'ul' list. Right now everything shows up, so all ul's are displayed. I tryed to add another 'while' loop but everything got broken.
I'm…

Mickael B
- 13
- 1
- 3
0
votes
1 answer
Uploading and storing CSV into mysql db using PHP
I'm trying to create a file upload form in which te user can simply upload a CSV and then it's parsed and values are uploaded in a mysql database. I have already managed to get a lot of my code working. Here's what I have so far:
HTML of upload…
user2568495
0
votes
1 answer
Function fgetcsv won't parse file without blank line at end of file
I'm working on a script to run through a CSV file (see previous post).
I ran into a weird thing, where if my actual CSV file itself has a blank line at the end of it, it will open and parse just fine, but if it doesn't, if the end of the file ends…

mrpatg
- 10,001
- 42
- 110
- 169
0
votes
1 answer
How to get CSV values based on unique column (if unique column found loop its some columns)
I have a CSV file who has row by row data. The scenerio is that 2 of my columns have same values all the time.
Suppose, if in the row 1, column 0 and column 1 have the same value it simple store it in array first with its other values whom I want…
user3963491
0
votes
2 answers
How to upload csv file using php into mysql?
How to upload csv file using php into mysql database correctly?
I have a column (uploaded, column name) in phpmyadmin, in this column will store the uploaded csv file.
I have a little script of uploading csv file into mysql database, but I'm…

User014019
- 1,215
- 8
- 34
- 66
0
votes
2 answers
Edit CSV field value for entire column
I have a CSV that is downloaded from the wholesaler everynight with updated prices.
What I need to do is edit the price column (2nd column) and multiply the current value by 1.3 (30%).
My code to read the provided CSV and take just the columns I…

BubbleMeda
- 1
- 1
- 5
0
votes
1 answer
Loading CSV file into mysql database using php
I ma struggling to load information from a csv file using PHP and want to save the contents of csv (mobile phone numbers) into mysql database table.The file contents look like this:
CSV file contents ( individual record per single line with no…

user3489398
- 9
- 4
0
votes
0 answers
fgetcsv return special charterer when try to read persion language file
I'm working on CSV import / export system in persian language.
I have created script for export file. For I have used following header in php:
header('Content-Type: ' . $mime_type);
header('Content-Disposition: attachment;…

Sandeep Solanki
- 702
- 1
- 6
- 15
0
votes
2 answers
How to store key-value pairs in a .csv file and then retrieve them as an associative array?
When I apply the following piece of code for a .csv file containing contents: WaterMelon,BlueBerry,BlackBerry, I get the output: Array ( [0] => WaterMelon, [1]=>BlueBerry, [2]=>BlackBerry )
The output I have got is a simple array, because I had…

Solace
- 8,612
- 22
- 95
- 183
0
votes
1 answer
How to parse tab-delimited file into mysql database
I was tasked with parsing a tab-delimited file and inserting the values into the database. Find a selection of the tab-delimited file below.
"030-36-2" 0 0 14 "P"
"030-38-2" 0 0 14 "S"
"030-40-2" 0 0 14 "S"
"031-2-2" …

jdmney
- 33
- 1
- 3
0
votes
1 answer
fgetcsv with MySQL : weird error
I'm trying to import a relatively big csv file into my database (7500+ lines, 43 columns) and i'm running into some strange error.
$file = fopen(APPLICATION_PATH."/../docs/data.csv", "r");
while (($emapData = fgetcsv($file, 100000, ";")) !==…

slayne
- 17
- 1
- 4
0
votes
0 answers
fgetcsv to fetch data within double quotes
I am trying to upload csv file data using PHP,
CSV File Data (Semicolon separated)
Name;Nom;Tel;Email;Ville;ID
x;DURAND;11;aprasquier+testvia@odm-tech.com;"Paris";1
PHP Code:
$handle = fopen('test.csv', "r");
while (($data = fgetcsv($handle,0, …

Ayyanar G
- 1,545
- 1
- 11
- 24