Forum Discussion
TT
2 years agoNew Contributor III
Reading dictionary type
I am using below sql to get validation messages from the workflow transformation process to be used in Transformation Event Handler. But, I need to put the output of this dictionary into a flat file...
Henning
OneStream Employee
2 years agoHi, how about instead of writing the results into a dictionary, use your existing data table (dtValidation) and save it as a CSV directly.
This post should get you where you want to be:
Solved: Saving an export directly to the shared folder - OneStream Community (onestreamsoftware.com)
- DanielWillis2 years agoValued Contributor
I agree, if you can do this during your initial for loop then it would save doing more potentially redundant looping down the track.
I would also suggest including more detail in your code to at least show the definition of the variable that you're asking about.
It looks like your dictionary contains a list of strings for each key. I would strongly advise doing it in your datarow loop but here is some generic VB.net code that could have assisted if that option was not available:
' Specify the file path for the CSV file Dim filePath As String = "errorOutput.csv" ' Generate CSV output Using writer As New StreamWriter(filePath) ' Write the header (optional) writer.WriteLine("Error Code,Description") ' Iterate through the dictionary For Each kvp As KeyValuePair(Of String, List(Of String)) In errorDict Dim key As String = kvp.Key For Each value As String In kvp.Value ' Write the key and value to the CSV file writer.WriteLine($"{key},{value}") Next Next End Using
Related Content
- 4 years ago
- 2 years ago
- 2 years ago
- 4 years ago
- 2 years ago