Return to Snippet

Revision: 32996
at October 5, 2010 07:20 by hoffstein


Updated Code
using System;
using System.IO;
using System.Text;

namespace RedHook.Utils
{
    public class CsvWriter
    {
        public static void Write(string[][] data, string outputPath)
        {
            if (data == null) throw new ArgumentException("Parameter \"data\" cannot be null");
            if (outputPath == null) throw new ArgumentException("Parameter \"outputPath\" cannot be null");

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < data.GetLength(0); i++)
            {
                if (data[i] == null) continue;
                sb.AppendLine(string.Join(",", data[i]));
            }
            File.WriteAllText(outputPath, sb.ToString());
        }
    }
}

Revision: 32995
at October 5, 2010 07:19 by hoffstein


Initial Code
using System;
using System.IO;
using System.Text;

namespace RedHook.Utils
{
    public class CsvWriter
    {
        public static void Write(string[][] data, string outputPath)
        {
            if (data == null) throw new ArgumentException("Parameter \"data\" cannot be null");
            if (outputPath == null) throw new ArgumentException("Parameter \"outputPath\" cannot be null");

            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < data.GetLength(0); i++)
            {
                if (data[i] == null) break;
                sb.AppendLine(string.Join(",", data[i]));
            }
            File.WriteAllText(outputPath, sb.ToString());
        }
    }
}

Initial URL

                                

Initial Description

                                

Initial Title
Simple CSV Writer

Initial Tags
csv

Initial Language
C#