RE: Commas conundrum

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

 



Hey Anne.  How are you "importing" the file?   Looks like your comma
delimited file also uses double-quotes to delineate the data (which is
normal for CSVs).  I'd say just split the lines on the commas (as you're
probably doing) with explode or something, then count how many entries
you got.  If it's more than the number of columns you're looking for,
parse through the data to find where you have some quotes and
concatenate the offending columns.

Or look for the quotes and merge those two items that way.


It should be fairly predictable.  You either have  ,data,  or you have
,"data, data",  (with or without the middle comma).  There shouldn't be
too many other variants to the data structure.


Someone probably has a much more clever way of doing this like with
regex's or something, but it's all about how you're collecting your
data.

Good luck!

-TG

> -----Original Message-----
> From: Anne Shroeder [mailto:anne@xxxxxxxxxxxxxxxxxx] 
> Sent: Friday, October 01, 2004 8:25 PM
> To: PHP-windows@xxxxxxxxxxxxx
> Subject:  Commas conundrum
> 
> 
> I'm trying to import a .csv file into a table.  One of the 
> columns of the
> .csv file looks like this:  Manila, Philippines. I want this 
> data to go into
> one field:  "address"
> 
> When I do the import with stripslashes (magic_quotes_gpc is 
> turned on) it
> does this:
> 
> insert into helpdesk values( '0',  '"Manila', 'Philippines"')
> 
> which obviously doesn't work.  What am I doing wrong?
> 
> Anne
> 
> 
> -- 
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux