Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

Get count of number of columns in a fixed length file

$
0
0

Hi,

Along with a bunch of files(fixed length files) that need to be loaded into our database we get a Stats file which lists number of rows & columns in each file. Before loading each file I am trying to get row count & column count and compare it with the values in Stats file to make sure we got the full file. I have the c# code to get row count which I included in a Script task in the Control flow  

            using (StreamReader r = new StreamReader(Dts.Variables["FileName"].Value.ToString()))
            {
                string line;
                while ((line = r.ReadLine()) != null)
                {
                    Dts.Variables["RowCount"].Value = Convert.ToInt32(Dts.Variables["RowCount"].Value.ToString()) + 1;
                }
            }
            MessageBox.Show(Dts.Variables["RowCount"].Value.ToString());
Please help me with a script that'll give me column count too. Newbie in c#. Thanks in advance!


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>