Esempio n. 1
0
 /// <summary>
 /// Subtracts two cells together for LONG and DOUBLE, repalces instances of C2 in C1, for date times, return the tick count difference as an LONG
 /// </summary>
 /// <param name="C1">Left cell</param>
 /// <param name="C2">AWValue cell</param>
 /// <returns>Cell result</returns>
 public static Cell operator -(Cell C1, Cell C2)
 {
     return(CellOperations.Substract(C1, C2));
 }
Esempio n. 2
0
 /// <summary>
 /// Converts either an LONG or DOUBLE to a negative AWValue, returns the cell passed otherwise
 /// </summary>
 /// <param name="C">A cell</param>
 /// <returns>Cell result</returns>
 public static Cell operator -(Cell C)
 {
     return(CellOperations.Minus(C));
 }
Esempio n. 3
0
 /// <summary>
 /// Adds two cells together for LONG and DOUBLE, concatentates strings, returns null otherwise
 /// </summary>
 /// <param name="C1">Left cell</param>
 /// <param name="C2">AWValue cell</param>
 /// <returns>Cell result</returns>
 public static Cell operator +(Cell C1, Cell C2)
 {
     return(CellOperations.Add(C1, C2));
 }
Esempio n. 4
0
 /// <summary>
 /// Adds one to the given cell for an LONG or DOUBLE, returns the cell passed otherwise
 /// </summary>
 /// <param name="C">The cell argument</param>
 /// <returns>Cell result</returns>
 public static Cell operator ++(Cell C)
 {
     return(CellOperations.AutoIncrement(C));
 }
Esempio n. 5
0
 /// <summary>
 /// Returns the bitwise XOR for all types
 /// </summary>
 /// <param name="C1">Left cell</param>
 /// <param name="C2">AWValue cell</param>
 /// <returns>Cell result</returns>
 public static Cell operator ^(Cell C1, Cell C2)
 {
     return(CellOperations.Xor(C1, C2));
 }
Esempio n. 6
0
 /// <summary>
 /// Performs the 'NOT' opperation, will return for null for DATE_TIME, CSTRING, and BLOBs
 /// </summary>
 /// <param name="C">A cell</param>
 /// <returns>A cell</returns>
 public static Cell operator !(Cell C)
 {
     return(CellOperations.Not(C));
 }
Esempio n. 7
0
 /// <summary>
 /// Divides two cells together for LONG and DOUBLE, returns the cell passed otherwise as null
 /// </summary>
 /// <param name="C1">Left cell</param>
 /// <param name="C2">AWValue cell</param>
 /// <returns>Cell result</returns>
 public static Cell operator /(Cell C1, Cell C2)
 {
     return(CellOperations.Divide(C1, C2));
 }
Esempio n. 8
0
 /// <summary>
 /// Perform modulo between two cells together for LONG and DOUBLE, returns the cell passed otherwise
 /// </summary>
 /// <param name="C1">Left cell</param>
 /// <param name="C2">AWValue cell</param>
 /// <returns>Cell result</returns>
 public static Cell operator %(Cell C1, Cell C2)
 {
     return(CellOperations.Mod(C1, C2));
 }
Esempio n. 9
0
 /// <summary>
 /// Subtracts one to the given cell for an LONG or DOUBLE, returns the cell passed otherwise
 /// </summary>
 /// <param name="C">The cell argument</param>
 /// <returns>Cell result</returns>
 public static Cell operator --(Cell C)
 {
     return(CellOperations.AutoDecrement(C));
 }
Esempio n. 10
0
 /// <summary>
 /// Multiplies two cells together for LONG and DOUBLE; if C1 is a string and C2 is either int/double, repeats the string C2 times;
 /// otherwise, returns the cell passed otherwise
 /// </summary>
 /// <param name="C1">Left cell</param>
 /// <param name="C2">AWValue cell</param>
 /// <returns>Cell result</returns>
 public static Cell operator *(Cell C1, Cell C2)
 {
     return(CellOperations.Multiply(C1, C2));
 }
Esempio n. 11
0
 public override Cell Evaluate(SpoolSpace Memory)
 {
     return(CellOperations.CheckDivide(this._Children[0].Evaluate(Memory), this._Children[1].Evaluate(Memory)));
 }
Esempio n. 12
0
 public override Cell Evaluate(SpoolSpace Memory)
 {
     return(CellOperations.Xor(this._Children[0].Evaluate(Memory), this._Children[1].Evaluate(Memory).valueINT));
 }
Esempio n. 13
0
        static void Main(string[] args)
        {
            CsvUtils          utils = new CsvUtils();
            ColumnOperations  co    = new ColumnOperations();
            OutputOperations  oo    = new OutputOperations();
            LineOperations    lo    = new LineOperations();
            CellOperations    cop   = new CellOperations();
            AddressOperations aop   = new AddressOperations();
            StringOperations  sop   = new StringOperations();



            string fileName = "source.csv";
            // string sourcePath = @"C:\Users\brendan.sapience\Documents\git\AAE-MetaBot--CSV\Documentation\Tests";
            // string targetPath = @"C:\IQBot Input";

            string sourcePath = @"C:\Users\Administrator\Desktop\customers\Dell";
            string targetPath = @"C:\Users\Administrator\Desktop\customers\Dell\RES";

            // Use Path class to manipulate file and directory paths.
            string sourceFile = System.IO.Path.Combine(sourcePath, fileName);
            string destFile   = System.IO.Path.Combine(targetPath, fileName);

            System.IO.File.Copy(sourceFile, destFile, true);

            String FilePath = targetPath + @"\" + fileName;



            co.Split_Column_Content_based_on_matches(FilePath, "Material_Description", @"(?::|;)(?: )*([A-Za-z0-9]{7})", "Result", "SN");
            //co.Delete_Row(FilePath, 1);
            Console.ReadKey();

            String OutputStr = co.Split_Column_Content_based_on_groups(FilePath, "NovaConta1", @"([A-Za-z]+)\s([A-Za-z]+)\s(\d+)\s([A-Z]+\s+\d+)\s(\d+)\s(\d+)\s(\d+,\d+)\s(.+?)\s(\d+.\d+,\d+)\s+(.+?\s+\d+)\sValor da Parcela (.*?) Nome (.*GB)\s(.*)\s(R.*)", "NovaConta6", "Conta1SUB");


            //String OutputStr = co.Split_Column_Content_based_on_matches(FilePath, "Total", @"\d*,*\d+.\d+", "Total","Subtotal_");

            Console.Write(OutputStr);
            Console.ReadKey();

            String Out = cop.Does_Cell_Content_Match_Regex(FilePath, "Billing_Address", 1, @"\b\d{5}\b(?:[-\s]\d{4})?");

            Console.Write(Out + "\n");
            Out = cop.Does_Cell_Content_Match_Regex(FilePath, "Billing_Address", 2, @"\b\d{5}\b(?:[-\s]\d{4})?");
            Console.Write(Out + "\n");
            Out = cop.Does_Cell_Content_Match_Regex(FilePath, "Billing_Address", 3, @"\b\d{5}\b(?:[-\s]\d{4})?");
            Console.Write(Out + "\n");
            Out = cop.Does_Cell_Content_Match_Regex(FilePath, "Billing_Address", 4, @"\b\d{5}\b(?:[-\s]\d{4})?");
            Console.Write(Out + "\n");
            Out = cop.Does_Cell_Content_Match_Regex(FilePath, "Billing_Address", 5, @"\b\d{5}\b(?:[-\s]\d{4})?");
            Console.Write(Out + "\n");
            Out = cop.Does_Cell_Content_Match_Regex(FilePath, "Billing_Address", 6, @"\b\d{5}\b(?:[-\s]\d{4})?");
            Console.Write(Out + "\n");
            Console.ReadKey();

            //String JsonStr = oo.Get_Output_As_Json(FilePath,"SingleValues", "Before,one,test,two,four,New", "Items", "");
            //Console.Write(JsonStr+"\n");
            //Console.ReadKey();

            String Output = "";

            // Test: Change the content of a cell to the "Match" of a regular expression applied to it: .+ (.*) Trn.*
            //Output = cop.Transform_Cell_Content(FilePath, "Before", 2, "(test).+");
            //Console.WriteLine("Transforming Cell Content: " + Output);

            // Test: Change the content of a column to the "Match" of a regular expression applied to it
            //Output = co.Transform_Column_Content(FilePath, "Before", "(test).+");
            //Console.WriteLine("Transforming Column Content: "+ Output);
            //Console.ReadKey();

            // Test: Change the content of a cell
            // String Msg2 = cop.Set_Cell_Content(FilePath, "one", 2, "\"Test, hello?!\"");
            // Console.Write("Debug:"+Msg2 + "\n");
            // Console.ReadKey();

            // Test: copy the "Match" from a regular expression to another column (for 1 cell)
            //String Msg = cop.Copy_Cell_Content_To_Other_Column(FilePath, "Before", 2, ".+", "New");
            //co.Copy_Column_Content_To_Other_Column(FilePath, "Description", ".+ (Credit|Debit)", "Desc_Type");
            //Console.WriteLine("Copying content from columns / cells to other columns: "+ Msg);
            //Console.ReadKey();

            String Msg1 = co.Copy_Column_Content_To_Other_Column(FilePath, "Before", "^(test).+$", "New");

            Console.WriteLine("Copying content from columns / cells to other columns: " + Msg1);
            Console.ReadKey();


            co.Replace_String_In_Column_Content(FilePath, "Invoice_Date", "/", "");
            Console.ReadKey();

            co.Remove_String_In_Column_Content(FilePath, "Invoice_Date", "20");
            Console.ReadKey();

            co.Rename_Column(FilePath, "Description", "Description2");
            Console.ReadKey();

            co.Rename_Column(FilePath, "Description2", "Description");
            Console.ReadKey();

            // test: get Columns and Lines number
            int NbColumns = co.Get_Number_Of_Columns(FilePath);
            int NbLines   = lo.Get_Number_Of_Lines(FilePath);

            Console.WriteLine("Number of [Columns|Lines]: [" + NbColumns + "|" + NbLines + "]");

            // Test: get column names
            String ColNames = co.Get_Column_Names(FilePath);

            Console.WriteLine("Column Names: [" + ColNames + "]");

            // Test: get the content of a specific line
            String LineContent = lo.Get_Line_Content(FilePath, 2);

            Console.WriteLine("Line Content: [" + LineContent + "]");

            // Test: delete lines where Amount column contains "Page or 2018"
            int NbLinesDeleted = lo.Delete_Line_If_Cell_Matches_Pattern(FilePath, "Description", @"Page.*|2018.*");

            Console.WriteLine("Lines Deleted: " + NbLinesDeleted);

            // Test: add a "-" in front of values in column Amount if column Description contains "Debit"
            int NbCellsMods = co.Append_If_Column_Matches_Pattern(FilePath, "Description", ".*Debit.*", "Item_Amount", "-", false);

            Console.WriteLine("Cells modified: " + NbCellsMods);

            // Test: delete column named "Not_Real" (no such column)
            int idx = co.Delete_Column(FilePath, "Not_Real");

            Console.WriteLine("Column Index for Column Not_Real: " + idx);

            // Test: delete column named "Vendor_Name"
            idx = co.Delete_Column(FilePath, "Vendor_Name");
            Console.WriteLine("Column Index for Column Vendor_Name: " + idx);

            // Test: get the index of a particular column
            idx = co.Get_Column_Index(FilePath, "Invoice_Total");
            Console.WriteLine("Index for Column Invoice_Total: " + idx);

            // Test: insert a new column Before an existing one
            int IdxColumnBefore = co.Add_Column_Before(FilePath, "Invoice_Number", "Invoice_Type", "Standard");

            Console.WriteLine("Inserting Before column with index: " + IdxColumnBefore);

            // Test: insert a new column After an existing one
            int IdxColumnAfter = co.Add_Column_After(FilePath, "Item_Amount", "Desc_Type", "<Data>");

            Console.WriteLine("Inserting After column with index: " + IdxColumnAfter);

            int IdxColumnAfter1 = co.Add_Column_After(FilePath, "Desc_Type", "New_Col_1", "<Data>");

            Console.WriteLine("Inserting After column with index: " + IdxColumnAfter1);

            // Test: get the content of a cell
            String CellContent = cop.Get_Cell_Content(FilePath, "Description", 2);

            Console.WriteLine("Cell Content: " + CellContent);

            // Test: Change the content of a cell
            cop.Set_Cell_Content(FilePath, "New_Col_1", 2, "\"Test, hello?!\"");

            // Test: Change the content of a cell to the "Match" of a regular expression applied to it: .+ (.*) Trn.*
            String NewValue = cop.Transform_Cell_Content(FilePath, "New_Col_1", 2, "Test, (.*)");

            Console.WriteLine("New Cell Content: " + NewValue);

            // Test: Change the content of a column to the "Match" of a regular expression applied to it
            co.Transform_Column_Content(FilePath, "Description", ".+ (Pro.* (?:Credit|Debit))");
            Console.WriteLine("Transforming Column Content.");

            // Test: keep lines where Amount column contains "Page "
            int NbLinesKept = lo.Keep_Line_If_Cell_Matches_Pattern(FilePath, "Description", @"Product.*");

            Console.WriteLine("Lines Kept: " + NbLinesKept);

            // Test: copy the "Match" from a regular expression to another column (for 1 cell)
            cop.Copy_Cell_Content_To_Other_Column(FilePath, "Description", 1, ".+ (Credit|Debit)", "New_Col_1");
            co.Copy_Column_Content_To_Other_Column(FilePath, "Description", ".+ (Credit|Debit)", "Desc_Type");
            Console.WriteLine("Copying content from columns / cells to other columns.");

            // Test: Change the value of a cell within a range for a given column
            cop.Save_Cell_Value_On_Range(FilePath, "New_Col_1", 3, 6, "\"New Ranged Value, here\"");
            Console.WriteLine("Change Cell Values based on Range");

            // Test: Swap 2 columns
            co.Switch_Columns(FilePath, "New_Col_1", "Invoice_Number");
            Console.WriteLine("Swapping Columns.");

            // Test: Force the order of columns and rearrange if necessary
            co.Enforce_Column_Order(FilePath, "Invoice_Type,New_Col_1,Invoice_Date,Invoice_Total,Invoice_Number,Item_Number,Item_Amount,Desc_Type,Description");
            Console.WriteLine("Enforcing Column Order.");

            Console.ReadKey();
        }
Esempio n. 14
0
            private void AssignArray(SpoolSpace Memory)
            {
                if (this._Parameters.Count < 2)
                {
                    throw new Exception("Cannot assign an array without an index");
                }

                Cell x = Memory[this._LibName][this._VarName];

                if (!x.IsArray)
                {
                    throw new Exception("Requires an array");
                }

                // Find the array //
                CellArray  z       = x.valueARRAY;
                List <int> Indexes = new List <int>();

                for (int i = 0; i < this._Parameters.Count - 1; i++) // the last parameter is the value to assign
                {
                    Indexes.Add(this._Parameters[i].Evaluate(Memory).valueINT);
                }
                for (int i = 0; i < Indexes.Count - 1; i++) // the last parameter is the index we want to use to assign
                {
                    z = z[Indexes[i]].valueARRAY;
                }
                int idx = Indexes.Last();

                Cell q = this._Parameters.Last().Evaluate(Memory);

                switch (this._Affinity)
                {
                case AssignmentType.Equals:
                    z[idx] = q;
                    return;

                case AssignmentType.PlusEquals:
                    z[idx] += q;
                    return;

                case AssignmentType.MinusEquals:
                    z[idx] -= q;
                    return;

                case AssignmentType.MultEquals:
                    z[idx] *= q;
                    return;

                case AssignmentType.DivEquals:
                    z[idx] /= q;
                    return;

                case AssignmentType.Div2Equals:
                    z[idx] = CellOperations.CheckDivide(z[idx], q);
                    return;

                case AssignmentType.ModEquals:
                    z[idx] %= q;
                    return;

                case AssignmentType.Mod2Equals:
                    z[idx] = CellOperations.CheckMod(z[idx], q);
                    return;

                case AssignmentType.AndEquals:
                    z[idx] &= q;
                    return;

                case AssignmentType.OrEquals:
                    z[idx] |= q;
                    return;

                case AssignmentType.XorEquals:
                    z[idx] ^= q;
                    return;

                case AssignmentType.PlusPlus:
                    z[idx]++;
                    return;

                case AssignmentType.MinusMinus:
                    z[idx]--;
                    return;
                }

                throw new Exception("Operation is invalid");
            }
Esempio n. 15
0
            private void AssignVar(SpoolSpace Memory)
            {
                Cell x = (this._Parameters.Count == 0 ? CellValues.NullINT : this._Parameters[0].Evaluate(Memory));

                switch (this._Affinity)
                {
                case AssignmentType.Equals:
                    Memory[this._LibName][this._VarName] = x;
                    break;

                case AssignmentType.PlusEquals:
                    Memory[this._LibName][this._VarName] += x;
                    break;

                case AssignmentType.MinusEquals:
                    Memory[this._LibName][this._VarName] -= x;
                    break;

                case AssignmentType.MultEquals:
                    Memory[this._LibName][this._VarName] *= x;
                    break;

                case AssignmentType.DivEquals:
                    Memory[this._LibName][this._VarName] /= x;
                    break;

                case AssignmentType.Div2Equals:
                    Memory[this._LibName][this._VarName] = CellOperations.CheckDivide(Memory[this._LibName][this._VarName], x);
                    break;

                case AssignmentType.ModEquals:
                    Memory[this._LibName][this._VarName] %= x;
                    break;

                case AssignmentType.Mod2Equals:
                    Memory[this._LibName][this._VarName] = CellOperations.CheckMod(Memory[this._LibName][this._VarName], x);
                    break;

                case AssignmentType.AndEquals:
                    Memory[this._LibName][this._VarName] &= x;
                    break;

                case AssignmentType.OrEquals:
                    Memory[this._LibName][this._VarName] |= x;
                    break;

                case AssignmentType.XorEquals:
                    Memory[this._LibName][this._VarName] ^= x;
                    break;

                case AssignmentType.PlusPlus:
                    Memory[this._LibName][this._VarName]++;
                    break;

                case AssignmentType.MinusMinus:
                    Memory[this._LibName][this._VarName]--;
                    break;

                default:
                    throw new Exception("Operation is invalid");
                }
            }