Starbeamrainbowlabs

Stardust
Blog

CSVWriter - Easy CSV Generation

Gears from brm.io

Recently I've done a group project at University. As part of this, I wrote a C♯ class specially to make generating CSV files easy. It didn't get used in the end, but I've still kept it since it sounds like the kind of thing that would be rather useful. I also decided to share it here for anyone else who needs to do this kind of thing.

You can find it on GitHub gist: CSVWriter.cs

I have written tests for it in a Visual Studio Unit Testing project, but I can't really fgure out how to include them neatly in a gist.

Here's an example of how you would use it:

CSVWriter c = new CSVWriter("file.csv");
c.WriteHeader(new string[]{ "Number", "Data" });
for(int i = 0; i < 100; i++)
{
    c.WriteRecord(new string[]{ i.ToString(), "data" });
}
c.Close();

The whole thing is fully commented with intellisense comments, so they should help if you get a bit stuck. If you can't figure out how to use it, simply post a comment down below and I'll try and help you as best I can.

Before I go, I want to mention that the animated gif I used at the top of this post is from @liabru's Gears. All credit goes to him for making them - I just recorded the animated gif :)

Tag Cloud

3d 3d printing account algorithms android announcement architecture archives arduino artificial intelligence artix assembly async audio automation backups bash batch blog bookmarklet booting bug hunting c sharp c++ challenge chrome os cluster code codepen coding conundrums coding conundrums evolved command line compilers compiling compression containerisation css dailyprogrammer data analysis debugging demystification distributed computing documentation downtime electronics email embedded systems encryption es6 features ethics event experiment external first impressions future game github github gist gitlab graphics hardware hardware meetup holiday holidays html html5 html5 canvas infrastructure interfaces internet interoperability io.js jabber jam javascript js bin labs learning library linux lora low level lua maintenance manjaro network networking nibriboard node.js operating systems own your code pepperminty wiki performance phd photos php pixelbot portable privacy problem solving programming problems projects prolog protocol protocols pseudo 3d python reddit redis reference releases rendering resource review rust searching secrets security series list server software sorting source code control statistics storage svg talks technical terminal textures thoughts three thing game three.js tool tutorial twitter ubuntu university update updates upgrade version control virtual reality virtualisation visual web website windows windows 10 xmpp xslt

Archive

Art by Mythdael