fputcsv

Is there a library that can write an RFC 4180 CSV file with PHP? [closed]

穿精又带淫゛_ 提交于 2019-11-29 22:59:37
I am aware of fputcsv, but according to this "wontfix" bug fputcsv does not correctly escape input, and its behavior will not be fixed for compatibility reasons. I would prefer an implementation that is compliant with RFC 4180 so Excel and LibreOffice can open it in all cases. I've tried googling for a library that does this correctly, but there doesn't seem to be a consensus on a decent third party library, instead commonly suggesting the defective fputcsv. I could always roll my own, but I'd prefer not to reinvent the wheel if at all possible. Charles It seems that every library out there

Avoid default quotes from csv file when using fputcsv

两盒软妹~` 提交于 2019-11-29 01:40:01
Avoid default quotes from csv using fputcsv fputcsv($fp, $array, ',', '"'); // OR fputcsv($fp, $array); In test.csv testname,045645765789,"""04.07.2012 12:10:52""" How to avoid above quotes here? Like below testname,045645765789,04.07.2012 12:10:52 John C Two double-quotes are used to escape double-quotes, so it looks like your date/time is already quoted. If you just want to get a correctly quoted CSV, you could try removing any existing double-quotes (this might be a bit brute force): $array = array('testname',045645765789,'"04.07.2012 12:10:52"'); $array = str_replace('"', '', $array);

Generate CSV file on an external FTP server in PHP

99封情书 提交于 2019-11-28 05:17:42
问题 I have some PHP code that successfully exports a MySQL table to a CSV file. I would like to add to that code, so instead of saving locally the CSL file is exported to/saved on an external FTP server. My current code: //open database connection require ('../database-config.php'); //name the file header('Content-Type: text/csv'); header('Content-Disposition: attachment;filename=exported-data.csv'); //SQL Query for Data $sql = "SELECT * FROM data;"; //Prepare Query, Bind Parameters, Excute Query

php fputcsv and enclosing fields

对着背影说爱祢 提交于 2019-11-28 03:27:38
问题 I was just about to ask the same questions as the question aksed here.... Forcing fputcsv to Use Enclosure For *all* Fields The question was When I use fputcsv to write out a line to an open file handle, PHP will add an enclosing character to any column that it believes needs it, but will leave other columns without the enclosures. For example, you might end up with a line like this 11,"Bob ",Jenkins,"200 main st. USA ",etc Short of appending a bogus space to the end of every field, is there

Avoid default quotes from csv file when using fputcsv

假如想象 提交于 2019-11-27 15:59:49
问题 Avoid default quotes from csv using fputcsv fputcsv($fp, $array, ',', '"'); // OR fputcsv($fp, $array); In test.csv testname,045645765789,"""04.07.2012 12:10:52""" How to avoid above quotes here? Like below testname,045645765789,04.07.2012 12:10:52 回答1: Two double-quotes are used to escape double-quotes, so it looks like your date/time is already quoted. If you just want to get a correctly quoted CSV, you could try removing any existing double-quotes (this might be a bit brute force): $array

fputcsv and newline codes

大兔子大兔子 提交于 2019-11-27 01:25:11
I'm using fputcsv in PHP to output a comma-delimited file of a database query. When opening the file in gedit in Ubuntu, it looks correct - each record has a line break (no visible line break characters, but you can tell each record is separated,and opening it in OpenOffice spreadsheet allows me to view the file correctly.) However, we're sending these files on to a client on Windows, and on their systems, the file comes in as one big, long line. Opening it in Excel, it doesn't recognize multiple lines at all. I've read several questions on here that are pretty similar, including this one ,

fputcsv and newline codes

此生再无相见时 提交于 2019-11-26 09:39:52
问题 I\'m using fputcsv in PHP to output a comma-delimited file of a database query. When opening the file in gedit in Ubuntu, it looks correct - each record has a line break (no visible line break characters, but you can tell each record is separated,and opening it in OpenOffice spreadsheet allows me to view the file correctly.) However, we\'re sending these files on to a client on Windows, and on their systems, the file comes in as one big, long line. Opening it in Excel, it doesn\'t recognize