Re: [PHP] Spreadsheet_Excel_Reader problem

[email protected] (Ashley Sheridan)
Newsgroups php.general
Message-ID <1268928933.2206.26.camel@localhost>
On Thu, 2010-03-18 at 12:12 -0400, Paul M Foster wrote:

> On Thu, Mar 18, 2010 at 08:57:00AM -0700, Tommy Pham wrote:
> 
> <snip>
> 
> > 
> > Personally, I find working with fixed widths is best.  The text file
> > might be larger but I don't have worry about escaping any type of
> > characters ;)
> 
> I find this impossible, since I never know the largest width of all the
> fields in a file. And a simple explode() call allows pulling all the
> fields into an array, based on a common delimiter.
> 
> Paul
> 
> -- 
> Paul M. Foster
> 


Explode won't work in the case of a comma in a field value.

Also, newlines can exist within a field value, so a line in the file
doesn't equate to a row of data

The best way is just to start parsing at the beginning of the file and
break it into fields one by one from there.

The bit I don't like about characters other than a comma being used in a
"comma separated values" file is that you can't automatically tell what
character has been used as the delimiter. Hence being asked by
spreadsheet programs what the delimiter is if a comma doesn't give up
what it recognises as valid fields.

Thanks,
Ash
http://www.ashleysheridan.co.uk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.