Re: Automated data upload for customers
| From: | Jasper Bryant-Greene | Date: | Sat, 20 Aug 2005 02:45:04 +0000 |
| Subject: | Re: Automated data upload for customers | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-220981@lists.php.net to get a copy of this message | ||
Richard Lynch wrote:
On Fri, August 19, 2005 3:47 pm, Jasper Bryant-Greene wrote:Very good point. It can still be solved relatively simply with PHP's string and/or regex functions though, although that would be rather pointless as a function already exists. Thanks for pointing out the function, I hadn't seen it before.For CSV, it's as simple as explode() the data by "\n" (perhaps strip out any "\r" before you start) and then explode() by ",". Depending on the software they're using, you might also need to remove any delimiters on each field of data, such as quote marks (").No, it's not that simple, as embedded commas can be inside of quotes, and then quote quote is used for quotes inside of quotes. Which is why PHP has a function for reading CSV files. http://php.net/fgetcsv I believe.
Unless of course the field is delimited with quotes and contains an embedded tab character? Just a guess, I haven't had any reason to use tab-delimited files before. JasperIf other file formats are possible as well as CSV, you might like to look at the PEAR "File Formats" packages[1].Now TAB delimited is generally easier than CSV as it IS as simple as reading a line and explode() on "\t"