This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import csv | |
parser = argparse.ArgumentParser(description="Converts a CSV file to an XML file") | |
parser.add_argument("csv", help="the path to the .CSV file") | |
parser.add_argument("xml", help="the path to the .XML file") | |
parser.add_argument("--root", help="root tag name", default="root") | |
parser.add_argument("--row", help="row tag name", default="row") | |
parser.add_argument("-v", "--verbose", help="increase output verbosity", action="store_true") | |
args = parser.parse_args() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string csvPath = "..."; | |
string xmlPath = "..."; | |
using (StreamReader streamReader = new StreamReader(new FileStream(csvPath, FileMode.Open))) | |
{ | |
// snag headers | |
string[] headers = streamReader.ReadLine().Split(','); | |
// col0="{0}" col1="{1}" coln="{n}" | |
string attributesFormat = string.Join(" ", headers.Select((colStr, colIdx) => string.Format("{0}=\"{{{1}}}\"", colStr, colIdx))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
public abstract class DataObject | |
{ | |
public override bool Equals(object obj) | |
{ | |
var dataObj = obj as DataObject; | |
if (dataObj == null) return false; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected MyImmutableObject(IDictionary<string, object> parameters) | |
{ | |
foreach (var field in GetType().GetFields().Where(x => parameters.Keys.Contains(x.Name))) | |
{ | |
if (parameters[field.Name] is Dictionary<string, object>) | |
{ | |
var ctor = field.FieldType.GetConstructor(new[] { typeof(Dictionary<string, object>) }); | |
var instance = ctor.Invoke(new object[] { parameters[field.Name] }); | |
field.SetValue(this, instance); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
public static class Math | |
{ | |
/// <summary> | |
/// Floating-point epsilon value. | |
/// </summary> | |
public const float FLT_EPSILON = 1.192092896e-07f; | |
/// <summary> |
NewerOlder