Example #1
0
        /// <summary>
        /// converts tab separated file to csv format
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="tf"></param>
        private static void CreateCsvFile(string filename, TextFile tf)
        {
            StreamWriter sw = new StreamWriter(filename);

            for (int i = 0; i < tf.Length; i++)
            {
                string[] tokens = Regex.Split(tf[i].Trim(), @"\t");
                for (int j = 0; j < tokens.Length; j++)
                {
                    tokens[j] = CsvFile.EncodeCSVCell(tokens[j]);
                }

                string output = String.Join(",", tokens);
                sw.WriteLine(output);
            }
            sw.Close();
        }