Re: Spreadsheet_Excel_Reader problem
| From: | Ashley Sheridan | Date: | Thu, 18 Mar 2010 16:15:33 +0000 |
| Subject: | Re: Spreadsheet_Excel_Reader problem | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-302970@lists.php.net to get a copy of this message | ||
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