Friday
I have the following problem:
I want to save a collection as a CSV file in a Sharepoint folder.
I know the Action Microsoft 365 Excel Write Collection. Is there something similar for CSV? Another option would be to first store the Excel file on Sharepoint and then convert it into a CSV file. So I would need to know how to convert an Excel file stored on Sharepoint into a CSV file?
Anybody got an idea?
yesterday - last edited yesterday
Hi @EasyBluePrism,
Thank you for being an SS&C Blue Prism customer, and for using Blue Prism.
Let me have a look around and see if there is an action on another asset that might help you.
regards
yesterday
Hi @GeoffHirst
Thank you, but I know this VBO, but it doesn’t help me. The problem is that I put my Excels and CSV on Sharepoint. That’s why I work with the Microsoft 365 VBOs. But I didn’t find anything analogous to the VBO you mentioned to write a CSV and put it on Sharepoint.
yesterday
HI @EasyBluePrism ,
Apologies for not being clearer previously. Have you looked at the following asset Blue Prism Digital Exchange ? This is the sharepoint Graph API asset and it does offer an option to upload a file to Sharepoint. However, you may need code to convert the Collection to a csv file, if that is the case, please let me know and I will see what I may be able to help you with.
regards
yesterday
Hi @GeoffHirst
I already use the Sharepoint Graph API intensively.
I was afraid that I would have to code the CSV conversion. It would be nice if you could help me with that.
yesterday - last edited yesterday
HI @EasyBluePrism ,
If you are ok creating code stages, the code is attached below:
Private Shared Sub SaveDataTableToCSV(ByVal dt As DataTable, ByVal csvFilePath As String, ByVal addHeadings As Boolean)
Dim csvData As StringBuilder = New StringBuilder()
If addHeadings Then
For i As Integer = 0 To dt.Columns.Count - 1
csvData.Append(dt.Columns(i).ColumnName)
If i < dt.Columns.Count - 1 Then
csvData.Append(",")
End If
Next
csvData.AppendLine()
End If
For Each row As DataRow In dt.Rows
For i As Integer = 0 To dt.Columns.Count - 1
csvData.Append(row(i).ToString())
If i < dt.Columns.Count - 1 Then
csvData.Append(",")
End If
csvData.AppendLine()
Next
Next
File.WriteAllText(csvFilePath, csvData.ToString())
End Sub
If you need the above in C#, let me know and I will see what I can do. Now this code will create a CSV file on a local file system, this may not be what you want, but you can see the variable that holds the CSV data and from there you should be able to send it wherever you need it to go. If you need further help, just let me know.
thanks
yesterday
That was quick! Thank you very much. But I will not have time to test this until Thursday. I will get back to you.
yesterday
Hi @EasyBluePrism ,
I noticed an issue with the previous code.
Private Shared Sub SaveDataTableToCSV(ByVal dt As DataTable, ByVal csvFilePath As String, ByVal addHeadings As Boolean)
Dim csvData As StringBuilder = New StringBuilder()
If addHeadings Then
For i As Integer = 0 To dt.Columns.Count - 1
csvData.Append(dt.Columns(i).ColumnName)
If i < dt.Columns.Count - 1 Then
csvData.Append(",")
End If
Next
csvData.AppendLine()
End If
For Each row As DataRow In dt.Rows
For i As Integer = 0 To dt.Columns.Count - 1
csvData.Append(row(i).ToString())
If i < dt.Columns.Count - 1 Then
csvData.Append(",")
End If
Next
csvData.AppendLine()
Next
File.WriteAllText(csvFilePath, csvData.ToString())
End Sub
The above is it corrected. I am adding this action to the Collection Manipulation tool and I expect it to be on the DX in the next few days if that helps you move forward quicker.
regards.