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

Sql table importing only first column

I want to upload a csv file into a sql table. Here is my code:
Claudiu Creanga
  • 8,031
  • 10
  • 71
  • 110
0
votes
3 answers

PHP fgetcsv - Skip columns?

I am trying to import a CSV, and be able to remove columns, and only import the ones selected. So I have an array of selected fields, and the CSV file. I can remove rows, but having problems skipping columns. Here is what i'm using to display a…
joepwn
  • 57
  • 1
  • 7
0
votes
1 answer

fgetcsv error inserting into the database

I am trying to insert a .txt file (converted to csv) into the database using the following: while (($data = fgetcsv($prop, 1000, ",")) !== FALSE) { When i try to do it with phpmyadmin with the file themselves it works, however the text does contain…
meohmy
  • 131
  • 7
  • 17
0
votes
2 answers

MySQL Is Not Inserting All Successful Insert Queries...Why?

Before I go on, this is purely a question of intuition. That is, I'm not seeking answers to work out specific bugs in my PHP/MySQL code. Rather, I want to understand what the range of possible issues that I need to consider in resolving my issue. …
-1
votes
1 answer

PHP script creates XML files from CSV's but holds 0 contents

I have created a php script to read through 19 csv files and normalises the data - not holding repeating data (station id, name & geocode) and only holding the attributes for each record which have values. I have printed the csv's to make sure the…
grimx
  • 5
  • 3
-1
votes
1 answer

Using fgetcsv to replace commans within numbers

I have the following CSV data: "Symbol","Name","Trade Volume","Trade Value","UIN Settlement Volume ","UIN Settlement Value ","UIN Percentage Volume","UIN Percentage Value " "786","786 INVESTMENT LIMITED","500.00"," 2,325.00 ","500.00"," 2,325.00…
Volatil3
  • 14,253
  • 38
  • 134
  • 263
-1
votes
1 answer

How to use fgetcsv() when the CSV has several double quotes """" or if the entire line is wrapped in quotes?

Some CSV files that we import to our server cannot be parsed correctly. We are reading the CSV file with PHP's fgetcsv(): while (($line = fgetcsv($file)) !== false) { ... } However, when the CSV line is wrapped in quotes (and contains two double…
Avatar
  • 14,622
  • 9
  • 119
  • 198
-1
votes
1 answer

PHP Get accurate record count when importing csv

I have a function that inside my class that is handled 3 pieces of data. filename to be parsed replace string which is basically the insert or replace text except for the values. the tablename to hold the data or delete for getting new data. My…
crosenblum
  • 1,869
  • 5
  • 34
  • 57
-1
votes
1 answer

Import of a CSV file into MySQL - database incomplete

I would like to update a database regularly by a CSV file. I have now thought about the following way: I put the CSV file on the server, establish an SSH connection with Putty and start a php script, which is located in the same folder as the CSV…
Dominic
  • 19
  • 3
-1
votes
1 answer

Upload CSV file and check if value is empy to set it = 0 php

I want to upload a csv file in my database. If a cell of the csv file is empty i want to set the value = 0 because it gives error Undefined offset. i tried to check the values in a for loop but it does not works. $msg = 0; if…
PX.
  • 5
  • 4
-1
votes
1 answer

PHP: Remove a row from a CSV if ID occurs multiple times and a column has a specific value

I have data as below in a CSV file. The green lines are what I'd like to keep. Basically if someone has a single line, I want to keep it. If they have multiple lines, I want to remove any where the 3rd column is A - Fully Fit. After running…
pee2pee
  • 3,619
  • 7
  • 52
  • 133
-1
votes
1 answer

Upload a CSV file via PHP and Insert Into MySQL DB

No error messages appear on the page. Upload File button works. Upload button doesn't trigger db insert but the page refreshes as if it did. I am not sure if the array of data from Excel is being coded correctly on the INSERT Into command. Any…
Vets
  • 76
  • 7
-1
votes
1 answer

How can i import null value in a csv file into my table of mysql?

I would like to know how I can import a CSV file with null values ​​to my MySQL table. This is the code I use in my PHP to import the CSV file to the MySQL table.
-1
votes
1 answer

fputcsv and fgetcsv

My code looks like this .. the o/p is a csv file with 4 values in ONE cell and so on in the FIRST column alone Better versions of this code please . ASAP foreach ($xml->xyz as $xyz) { $f = fopen('blahblahblah.csv', 'a') or die("can't open…
Zac
  • 695
  • 1
  • 11
  • 34
-1
votes
1 answer

PHP, Writing to CSV not on same line?

function writePlayerInfo($playerFName, $playerSName, $phone, $email){ $data = array(); array_push($data, $playerFName, $playerSName, $phone, $email); $handleName = fopen("data/names.csv","w"); foreach ($data as $line) { …
mattoakley
  • 11
  • 3