Re: Automated data upload for customers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, August 19, 2005 3:47 pm, Jasper Bryant-Greene wrote:
> Brian Dunning wrote:
>> I have a system where I'm trying to facilitate a process for
>> customers
>> to upload data to me (basically a list of people), and have  it go
>> into
>> a database. I can give them certain parameters, like it  has to be a
>> CSV
>> file, delimited in such a way, etc. but can't ask  much more of them
>> than that, since people are largely stupid.  :)
>
> 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.

> If 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"

-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux