I got stuck with having to create a CSV file in UTF-8 format without BOM. Luckily this link made that easy
The problem I am having now is that I need the output to be pipe delimited and the “Output Data Table” function seems to default to csv without any options. Any ideas?
I’m still testing this. My data table is large (the CSV is about 15MB). I’ve been waiting 2 hours for this additional command to finish and it is still running. Any idea why it would take so long? I cannot wait hours for this conversion unfortunately.
No compiled code to run
error BC30512: Option Strict On disallows implicit conversions from ‘System.IO.StreamWriter’ to ‘CsvHelper.ISerializer’. At line 2
error BC30456: ‘Encoding’ is not a member of ‘CsvHelper.Configuration.IWriterConfiguration’. At line 5
my arguments are a DT (with the data) and a string for the filename
Test with the code below instead. I have hard coded the namespace so UiPath shouldn’t complain anymore.
Dim sw As System.IO.StreamWriter = System.IO.File.CreateText(in_FileName)
Dim csv As CsvHelper.CsvWriter = New CsvHelper.CsvWriter(sw)
csv.Configuration.Delimiter = "|"
csv.Configuration.Encoding = New System.Text.UTF8Encoding(False)
' Write headers
For Each col As System.Data.DataColumn In in_DT.Columns
csv.WriteField(col.ColumnName)
Next col
csv.NextRecord
' Write rows
For Each row As System.Data.DataRow In in_DT.Rows
For i As Integer = 0 To row.ItemArray.Count-1
csv.WriteField(row(i))
Next
csv.NextRecord
Next row
sw.Close
' Clean up
sw.Dispose
csv.Dispose
Also remove the CsvHelper import you added. It seems like it has imported an older version of CsvHelper that are missing a lot of features.
Unfortunately i’m seeing the same error still. I am using your new code and I removed the csvhelpder from the import tab.
Error ERROR Validation Error No compiled code to run
error BC30512: Option Strict On disallows implicit conversions from ‘System.IO.StreamWriter’ to ‘CsvHelper.ISerializer’. At line 2
error BC30456: ‘Encoding’ is not a member of ‘CsvHelper.Configuration.IWriterConfiguration’. At line 5 Main.xaml
Between the first Invoke Code and the second Invoke Code, do you have any other CSV activities? It seems like your UiPath Studio is trying to access different versions of CsvHelper.
If you search of CsvHelper in your project, do you see different versions?
I have no issue invoking the code several times on my computer:
Here’s my last try. The code has been updated for CsvHelper 16.0.0. I have also removed the encoding line since CsvHelper doesn’t add BOM either way.
Dim sw As System.IO.StreamWriter = System.IO.File.CreateText(in_FileName)
Dim csv As CsvHelper.CsvWriter = New CsvHelper.CsvWriter(sw, System.Globalization.CultureInfo.InvariantCulture)
csv.Configuration.Delimiter = "|"
' Write headers
For Each col As System.Data.DataColumn In in_DT.Columns
csv.WriteField(col.ColumnName)
Next col
csv.NextRecord
' Write rows
For Each row As System.Data.DataRow In in_DT.Rows
For i As Integer = 0 To row.ItemArray.Count-1
csv.WriteField(row(i))
Next
csv.NextRecord
Next row
sw.Close
' Clean up
sw.Dispose
csv.Dispose