Example #1
0
        static void Main(string[] args)
        {
            String sOutputFile = "";
            String sInputFile  = "";

            String[] Fields = { };
            String   O;
            bool     bEcho = false;


            foreach (String Param in args)
            {
                if (Param == "-d")
                {
                    bEcho = true;
                }

                String[] Options = Param.ToLower().Split(':');
                O = Options[0].ToUpper();
                if (O == "-O")
                {
                    sOutputFile = Options[1];
                }
                if (O == "-I")
                {
                    sInputFile = Options[1];
                }
                if (O == "-FIELDS")
                {
                    Fields = Options[1].Split(',');
                }
            }


            if ((sInputFile == "") || (sOutputFile == "") || Fields.Count() == 0)
            {
                Usage();
                return;
            }

            ObjDataSet S;

            DataIO.Read(sInputFile, out S, true);
            ObjDataSet Extracted = DataIO.Extract(S, Fields);

            DataIO.Write(Extracted, sOutputFile);
            if (bEcho)
            {
                DataIO.Dump(Extracted);
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            //Compare 2 CSV files
            //Output the differences (either removed or added)
            ObjDataSet A, B;
            bool       TwoWay   = false;
            String     sFileOne = "";
            String     sFileTwo = "";

            String[] OutputFile = new string[2];
            bool     Echo       = false;
            String   O;

            foreach (String Param in args)
            {
                String[] Options = Param.ToLower().Split(':');
                if (Options.Count() == 2)
                {
                    O = Options[0].ToUpper();
                    if (O == "-OUTPUT")
                    {
                        TwoWay = true;
                    }
                    else if (O == "-A")
                    {
                        sFileOne = Options[1];
                    }
                    else if (O == "-B")
                    {
                        sFileTwo = Options[1];
                    }
                    else if (O == "-OA")
                    {
                        OutputFile[0] = Options[1];
                    }
                    else if (O == "-OB")
                    {
                        OutputFile[1] = Options[1];
                    }
                }
                if (Options.Count() == 1)
                {
                    O = Options[0].ToUpper();
                    if (O == "-ONEWAY")
                    {
                        TwoWay = false;
                    }
                    else if (O == "-TWOWAY")
                    {
                        TwoWay = true;
                    }
                    else if (O == "-D")
                    {
                        Echo = true;
                    }
                }
            }

            DataIO.Read(sFileOne, out A, true);
            DataIO.Read(sFileTwo, out B, true);


            //One way only

            ObjDataSet OutputA = DataIO.Diff(A, B, false);

            Console.WriteLine(sFileOne + " has " + OutputA.GetRowCount() + " additional records ");
            DataIO.Write(OutputA, OutputFile[0]);
            if (Echo)
            {
                DataIO.Dump(OutputA);
            }

            if (TwoWay)
            {
                ObjDataSet OutputB = DataIO.Diff(B, A, false);
                Console.WriteLine("\n" + sFileTwo + " has " + OutputB.GetRowCount() + " additional records ");
                DataIO.Write(OutputB, OutputFile[1]);
                if (Echo)
                {
                    DataIO.Dump(OutputB);
                }
            }
        }