Introduction to export REST API to CSV Export REST API to CSV is in some cases necessary to process the data because many tools can handle CSV files. In this new article, we will show different ways to export the data. The first example will do it using C#. The second example with use Python. Let’s take a […]
Tag Archives: c#
How to count file columns in SSIS using C# Script
Here is the snippet which can be used to count total columns in your flat file. Below script assume that you have column count based on separator=comma. if you use different separator then just change script accordingly
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
public void Main() { // TODO: Add your code here var colCnt = GetFileColumns("file1",','); MessageBox.Show("Your file has total " + colCnt + " columns"); Dts.TaskResult = (int)ScriptResults.Success; } private int GetFileColumns(string connName,char colSeperator= ',') { var filePath=Dts.Connections[connName].ConnectionString; string firstline; using (System.IO.StreamReader sr = new System.IO.StreamReader(filePath)) { firstline= sr.ReadLine(); } var colArr=firstline.Split(new char[]{colSeperator}); return colArr.Length; } |
SSIS check file is locked and wait until file is unlocked (C# Script)
Introduction In this small blog post you will learn How to move files using SSIS Advanced File System Task and How to wait until file is unlocked using C# Script Task. How to check if file is locked (SSIS C# Script Task) If you want to check if file is locked in C# then below […]
SSIS Code – Check URL Exists using C# Script – 404 Error
In this post you will learn how to use SSIS Script Task (C# Code) to detect specific URL found or not (Detect HTTP 404 Error) If you using SSIS JSON Source or our REST API Task then if URL/Document you trying to read not found then server may return 404 (Not Found) Exception. In order […]