The Output Data Table activity only supports comma as delimiter. If you want to use a custom delimiter you need to generate the CSV text yourself. You could e.g. use CSVHelper to write the CSV file. Use the following code in an Invoke Code activity:
Dim sw As StreamWriter = File.CreateText(in_FileName)
Dim csv As CsvWriter = New CsvWriter(sw)
csv.Configuration.Delimiter = ";"
csv.Configuration.Encoding = New System.Text.UTF8Encoding(False)
' Write headers
For Each col As DataColumn In in_DT.Columns
csv.WriteField(col.ColumnName)
Next col
csv.NextRecord
' Write rows
For Each row As 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
The line csv.Configuration.Encoding = New System.Text.UTF8Encoding(False) is actually not needed since CSVHelper seems to write without BOM by default.
It seems very complicated - I never imagined such a “small” issue would need solutions like these.
I managed to solve it two other ways though. Both simple enough so I could understand them myself.
Solution one was just to make use of string replace to replace all instances of
,
with
;
Solution two was to add headers and have the program I imported the files into, ignore the first line (the headers).
The intia issue and the reason I created this topic, was that if the CSV file was saved as UTF-8-BOM the program I imported the files into, would not recognize the date - but only on the first line (???).
If the file always has BOM of UTF-8, the following workflow removes first 3 bytes and it will be without BOM file. Probably we can use WriteCSV activity with this.
Beware if you go with Solution 1, that you will be replacing commas inside the cells also. E.g. the value “-2752,8” will become “-2752;8” which might not be what you want. You can get around the issue by using Regex.Replace to only replace commas outside quotes.