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
1
vote
2 answers

Save CSV Export to Server

I have the code below which triggers when a button is pressed in the WordPress admin panel. This opens a csv file called 'ss-stock-export.csv'. How can I save this file to my server in my uploads directory at wp-content/uploads/exports/? I tried to…
1
vote
5 answers

Data gets garbled when writing to csv with fputcsv() / fgetcsv()

There seems to be an encoding issue or bug in PHP with fputcsv() and fgetcsv(). The following PHP code: $row_before = ['A', json_encode(['a', '\\', 'b']), 'B']; print "\nBEFORE:\n"; var_export($row_before); print "\n"; $fh = fopen($file =…
donquixote
  • 4,877
  • 3
  • 31
  • 54
1
vote
1 answer

Add integrity checks to csv files with php

I have to generate large csv files that export data from database with some minimal processing of the raw data. The file is downloaded to the user, writing chunks with putcsv. My problem is that the download can stop before is done and the user…
user237329
  • 809
  • 1
  • 10
  • 27
1
vote
1 answer

PHP fputcsv insert into a new line in csv file

I have a file name checklist.csv I try to insert a new information in this file using php My method work and i can insert a new information in the file But i have a problem that the new information is near the past…
mohamad mohamad
  • 613
  • 9
  • 24
1
vote
1 answer

how to remove file in local storage after send email in laravel 5.4

$email = $this->subject($this->registrationBatch->retrieve()->emailSubject()); foreach($attachments as $file){ $email->attach($file) } return $email; how to unlink $file after send email ?
abdul hanan
  • 40
  • 1
  • 8
1
vote
0 answers

fputcsv sometimes doesn't write to the file if one of the values is missing/zero

So I am not sure how to fix this so that when a field is missing it writes NULL or zero (for count) instead of not creating the stats_file: $stat_file = fopen("./".$feed_id_str."/"."stats.csv", 'w'); $stat_arr = []; $stat_arr[] =…
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
1
vote
2 answers

Why won't my fputcsv work?

I cannot get the PHP built-in function fputcsv() to work. Here is what I've tried: error_reporting(E_ALL); ini_set('display_errors', 1); include('DBConn.php'); //My SQL server connection information include 'Helper/LogReport.php'; …
Mike
  • 1,853
  • 3
  • 45
  • 75
1
vote
2 answers

how to create another sheet while write data using fputcsv in php

I am using fputcsv for write data. It is working fine. what i need is i need to create another sheet like any name and i need to write data on that. How to do that? Please guide. I am not familiar with this. This is my code. $filename =…
shanthi Jagadeesh
  • 213
  • 1
  • 3
  • 10
1
vote
0 answers

PHP fputcsv: adding document properties

I've been searching around for a while about the possibility of adding document properties to a .csv file (such as the Author, the Program name and so on) like those you can add to an .xls file but I ended up founding NO documentation about this. Is…
Mark
  • 645
  • 2
  • 9
  • 27
1
vote
2 answers

Remove " from string in array

I've got a HTML form, which I need to store in DB, then write it to .csv and .txt . Everything work well, except the txt output give me some bad string. fputcsv function: private function fputcsv_custom1($fp, $array, $eol) { fputcsv($fp, $array,…
fletcher
  • 58
  • 8
1
vote
1 answer

php get data from csv and again write them to the same csv

I have a csv like this product_id,stock_unit 1, , 2, , 3, , 4, , 5, , 6, , Now in my php code I will get the product id and run a query to the database to get the stock unit from the database. After getting the stock unit for the product the script…
NewUser
  • 12,713
  • 39
  • 142
  • 236
1
vote
2 answers

file_get_contents from html explode, write to cell of spreadsheet

What I'm attempting to achieve is a tweezing of specific content from a URL's source via file_get_contents(), then explode() the mark-up around where that content lives, returning just the HTML formatted content, and then writing it to the single…
SJGaliardi
  • 21
  • 2
1
vote
1 answer

Unable to insert data in CSV file PHP

I am in process of inserting data in the desired CSV file from another CSV file. CSV file is creating fine with out any problem but its is not insert array data in file. It only inserts header on the first row. Below is code I am…
user5084534
1
vote
1 answer

PHP fputcsv is not working, Nor creating csvfiles

By which I am exporting all products into csv file, But my csvfile is not create, I am able to see variables output on screen.
Steve
  • 71
  • 1
  • 8
1
vote
0 answers

Ignore line breaks in fputcsv

I am currently trying to export a number of products from a custom CMS MYSQL database into a Magento compatible database. The products include product descriptions which is stored as HTML that was serialised in a "ob_data" array with some other…