Questions tagged [fputcsv]

fputcsv is a PHP function that formats a line (passed as a fields array) as CSV and writes it (terminated by a newline) to the specified file handle. `fputcsv` support started with PHP version 5.1.0.

354 questions
2
votes
1 answer

PHP exporting data to CSV in multiple sheets

Each day I run a cron where it finds data that has not been pulled/exported yet (via a column "exported" that contains a boolean) and this works fine. However, now I'd like to do a loop for each of the results and stick them in to the exported CSV…
DT.DTDG
  • 765
  • 1
  • 13
  • 31
2
votes
4 answers

PHP fputcsv showing long integers in excel as scientific notation

I have a simple script that outputs data from my database to a CSV file. My problem is that when I export mobile numbers, excel sees them as long integers and displays them in scientific notation. If I go to format cells and change it to a number…
2
votes
1 answer

How should array be formatted for fputcsv result to be horizontal not vertical?

My $array looks like this in source code of my browser; Array( [0] => 2015-01-15 [1] => 2015-02-15 [2] => 2015-03-15 ) My code to export this to a csv file is; $fp = fopen("file.csv", "w"); fputcsv($fp, $array) fclose($fp); The output of the…
mikelovelyuk
  • 4,042
  • 9
  • 49
  • 95
2
votes
1 answer

Add data to csv file in specific columns using PHP

I have a csv file which has 14 columns, and hundreds of rows. There is a header which is "sku","category","description","brand" etc. All data is allready there but I'm trying to add some image filenames inside the CSV, in some specific columns (…
mlclm
  • 725
  • 6
  • 16
  • 38
2
votes
2 answers

How to optimize a wp_query to CSV script?

I've made this script where I run a WP_Query() that gets maybe 2,000 records and growing. I want to be able to write these results to a CSV file. I have that working when the posts_per_page is set to 300 or less records. If I change posts_per_page…
Robbiegod
  • 954
  • 4
  • 14
  • 44
2
votes
1 answer

fputcsv with tab delimiter

I would like to create a CSV document with a tab delimiter. I've tried a lot of things and searched all over the internet but there isn't a single site with a working solutions. This is the script I'm using right now, but it is exporting without a…
Stefan
  • 249
  • 5
  • 17
2
votes
1 answer

How to write 2 arrays in csv file using php

I want to write 2 arrays in a csv file and display it horizontally. Array 1 Array ( [0] => Array ( [0] => 501 [1] => 8921 ) [1] => Array ( [0] => 502 [1] => 8446 …
Raj
  • 1,377
  • 6
  • 23
  • 48
2
votes
1 answer

fputcsv fails with queries over 20k records

Simply put, when im exporting query results to a csv, it goes smooth as silk till the query results reach about 20k-25k records. When I hit that mark, I get a blank white screen and the file thats created only has the header row and nothing else. I…
Stephen F
  • 43
  • 6
2
votes
3 answers

Parse text to a CSV-file with PHP

I want to parse text from my database into a CSV-file with PHP. The problem is that nothing is parsed to the file. function exportToCSV($output) { if(isset($output)) { $fp = fopen("skrivtest/test.csv", "w"); foreach($output…
user500468
  • 1,183
  • 6
  • 21
  • 36
2
votes
1 answer

Create a CSV file with PHP

I need to create a CSV file from a PHP array, I'm aware of the fputcsv() function. I've a recollection that a better function exists for this kind of stuff but I can't find it nor remember it's name. Does anyone know of such function or am I…
Alix Axel
  • 151,645
  • 95
  • 393
  • 500
2
votes
1 answer

Force fputcsv to enclose output in quotes

I found a couple of topics online about forcing to enclose the fputcsv output and found out that's not possible to do this. I need to enclose every output with quotes, because of some import requirements. Seperate words are working, but non-seperate…
user1681144
2
votes
1 answer

fputcsv and fwrite not working

I have followed the explanation given here to write the query result to a file. But in this case I have to open and write the files headers first. Then keep writing/appending the query results one by one for multiple queries. This appending part I…
Konika Chawla
  • 141
  • 2
  • 5
2
votes
3 answers

Force new line in CSV generated file in PHP

I am generating a CSV downloadable file in PHP. I have a problem that when I open file in MS Excell or Ubuntu Libre Office the formate is not like what is expected. I want this output but I can not force to start from new line. Name …
Noor
  • 1,351
  • 8
  • 27
2
votes
2 answers

fopen() / fputcsv( ) : error

Im looking for a way to export to a csv on the fly and came accross this. $list = array ( array('aaa', 'bbb', 'ccc', 'dddd'), array('123', '456', '789'), array('"aaa"', '"bbb"') …
cosmicsafari
  • 3,949
  • 11
  • 37
  • 56
1
vote
3 answers

PHP: creating CSV file with windows encoding

i am creating csv files with php. To write the data into my csv file, i use the php function "fputcsv". this is the issue: i can open the created file normally with Excel. But i cant import the file into a shopsystem (in this case "shopware"). It…
sentinel777
  • 129
  • 2
  • 4
  • 11