Welcome Guest, Not a member yet? Register   Sign In
Troublesome commas when using csv_from_result
#1

[eluser]jtotheb[/eluser]
I'm using the "csv_from_result" database utility function to export some address data from my db. However any address that has a comma in it screws the csv up as comma is seen as a delimiter.

Is there anyway to escape the comma on export?

Thanks for any advice!
#2

[eluser]SitesByJoe[/eluser]
I don't know if there is an automatic way to do it.

I would:

1. Query DB to get your records
2. Perform character replacement on each record as you pull from the db (change "," to "~" or something else odd you know wouldn't be used otherwise)
3. Add record to CSV file

Then do the same thing backwards.

Or, change the comma to its UTF-8/ASCII/URL-Encoded equivalent or something like that.
#3

[eluser]jtotheb[/eluser]
Hmmm I don't really want to do character replacement, i would rather escape it somehow.

Would the url encoded comma be seen as a comma still in MS Excel?
#4

[eluser]Derek Jones[/eluser]
What version are you using, jtotheb? You should have positive results from the current csv_from_result().
#5

[eluser]jtotheb[/eluser]
1.6.1 at the moment.

I added this in DB_utility on line 262

Code:
$out .= "\"$item\"".$delim;

Which does the trick. Not the best solution though.
#6

[eluser]jtotheb[/eluser]
Ah right, after having a look at the 1.6.2 code it looks much better. Thanks very much for pointing that out, i'll upgrade tomorrow!




Theme © iAndrew 2016 - Forum software by © MyBB