How to load a delimited file to a table in OneStream


In this post, we will look at how to load a delimited file to a table in OneStream.

I was working on a project, and my colleague raised this question. “Hey, I got a CSV file, is there a way I can load that to an OneStream table?”

Till that time I’ve never thought of doing something like that.

Here is how it can be done.

Here is the code that I wrote during the video.

Dim fileName As String = BRApi.Utilities.GetFileShareFolder(si, FileShareFolderTypes.ApplicationIncoming, Nothing).Replace("Incoming", String.Empty) & "\Groups\Everyone\pos.txt"
Dim fieldTokens As New List(Of String)
fieldTokens.Add("xfText#:[Market]")
fieldTokens.Add("xfText#:[Product]")
fieldTokens.Add("xfInt#:[Units]")
fieldTokens.Add("xfDec#:[Price]")
BRApi.Utilities.LoadCustomTableUsingDelimitedFile(si, SourceDataOriginTypes.FromFileShare, fileName, File.ReadAllBytes(fileName), ",", "External Tables", "POS", "Replace", fieldTokens, False)

A few things about fieldTokens.

If you want to use a default value for a particular column, you can do so by changing the token slightly to the one given below.

fieldTokens.Add("xfText#:[Product]:Cola")

Now if you want to replace missing values with a default one, you can do so using the following code

fieldTokens.Add("xfText#:[Product]::Cola")

Leave a comment

Your email address will not be published.