BusinessObjects Board

CSV + commas in field

I’m using this chunk of code to convert a dataprovider to a csv file


Sub ExportCSV() 

    Dim bodoc As busobj.Document 
    Dim boDP As busobj.DataProvider 
    
    Dim strOutputFileName As String 
    
    Set bodoc = ActiveDocument 
    Set boDP = bodoc.DataProviders.Item(1) 
    
    strOutputFileName = "C:\CSVOutput.csv" 
    
    Call boDP.ConvertTo(boExpAsciiCSV, 1, strOutputFileName) 
    
End Sub

When this converts the dp to the csv file, any commas in the fields remain there, thus creating more fields.

Is there a solution to this such as encapsulating the fields before they’re outputted to the csv file?


iamfyrestorm (BOB member since 2006-06-05)

Welcome to B:bob:B!

My advice is much like the old joke:[list]Patient: Doctor, my neck hurts when I bend it like this!
Doctor: Well, then don’t bend it that way![/list]I always use tab-delimited files, instead of CSV. Many import / export routines will honor quotes as encapsulation markers, but what if your data naturally contains quotes? You’re back to the same situation. I find Tab characters to be much more reliable, and almost any import routine that can handle CSV can also handle tab-delimited.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

If you want to save a DP in csv format using Full Client, please follow this link:

https://bobj-board.org/t/63414

Hope this helps


BO_Chief :us: (BOB member since 2004-06-06)

I tried using this code. It does not appear to be a true comma delimited format. The empty cells come out with ‘,#EMPTY,’ in the file. In a true comma delimited file it comes out as ‘,’. I cannot use a file with ‘,#EMPTY,’.

Any ideas?


bradyd :us: (BOB member since 2006-06-14)