cancel
Showing results for 
Search instead for 
Did you mean: 

Get Collection as CSV output is not a comma seperated values??

Sri_Krishna_Cha
Level 5
I am using collection as CSV and the output is not  comma seperated values. Is this how it works ? Any other action that can give me collection values as CSV ?
4 REPLIES 4

Anonymous
Not applicable
Hi, I am assuming that you are familiar with the use of code stage Create a code stage with 2 input parameters, CSV_File_Name_With_Path and Collection_Input and in the Code tab, paste the below code. Let me know if this does not work. Would be better if you add this as a separate action in the collection manipulation VBO, so that you will have to add only System.Text namespace in the 'Code Option' tab in the Initialise action.        If Collection_Input.Columns.Count = 0 Then Throw new ApplicationException(""Zero columns in collection"")    Dim objOututStream As StreamWriter  objOututStream = File.CreateText(CSV_File_Name_With_Path)  ''Dim Columns As New DataTable  Dim SB As StringBuilder = New StringBuilder()  For intColCnt As Integer = 0 To Collection_Input.Columns.Count - 1   SB.Append("""""""" + Collection_Input.Columns(intColCnt).ColumnName.ToString() + """""""")   If intColCnt Collection_Input.Columns.Count - 1 Then    SB.Append("","")   End If   Next  SB.Append(vbNewLine)  For intRowCnt As Integer = 0 To Collection_Input.Rows.Count - 1   For intColCnt As Integer = 0 To Collection_Input.Columns.Count - 1    SB.Append("""""""" + Collection_Input.Rows(intRowCnt)(intColCnt).ToString() + """""""")    If intColCnt Collection_Input.Columns.Count - 1 Then     SB.Append("","")    End If   Next   SB.Append(vbNewLine)  Next  objOututStream.WriteLine(SB.ToString())  objOututStream.Close  

NevilleWatson
Level 4
If you open the code stage you will see a list of delimiters in the code.  They are set to True or False.  Change the setting in the code for the delimiter you need.

IshanMahajan
Level 7
What is your ultimate goal ? i am hoping that you want to store the Collection values as a CSV file, if that is the case you can follow below steps.   1. Create a single row collection with one field. 2. Use Utility String VBO - > get collection as CSV action. 3. in input provide your collection, in output provide your single row collection field name, note that it is a text field not collection, use collectionName.fieldName 4. Next stage should use Utility File Management VBO - > Write Text file action, input your file name *.csv, in Text input parameter enter your single row collection, use collectionName.fieldName.   Run the process you should be able to write the collection as CSV file, comma seperated.

IshanMahajan
Level 7
Good and working suggestion by sibi_luke, very useful if any one wants to create csv with delimiter of choice.