Forum Moderators: coopster

Message Too Old, No Replies

Exporting Binary Database Results as Comma delimited CSV

         

paulmadillo

1:35 pm on Mar 27, 2008 (gmt 0)

10+ Year Member



Hi.

I'm writing a function to export results from a database as a comma delimited CSV file.

The problem I'm having is that the table I'm exporting contains Blob data which can sometimes contain commas which would then escape to the next column of the CSV.

I tried str_replace()ing the commas but obviously this will just corrupt the binary data in the Blobs.

Does anyone know a way around this?

Romeo

1:50 pm on Mar 27, 2008 (gmt 0)

10+ Year Member



Binary data does not fit well into a text string (as a CSV line finally is).

One way could be to encode the binary data with BASE64, so they get translated to 'text' and then can be handled more easily.

Kind regards,
R.

paulmadillo

1:52 pm on Mar 27, 2008 (gmt 0)

10+ Year Member



Thanks for your quick reply Romeo.