Example #1
0
 public static void helloWorld()
 {
     using (Pnyx p = new Pnyx())
     {
         p.readString("Hello World.");
         p.sed("World", "World, with love from Pnyx.."); // transforms each line
         p.grep("world", caseSensitive: false);          // filters each line
         p.writeStdout();
         p.compile();                                    // Builds processors and wires filters together
         p.process();                                    // Runs processors (All IO is done here)
     }
     // outputs: Hello World, with love from Pnyx...
 }
Example #2
0
        public void rowFilterShimOr()
        {
            String actual;

            using (Pnyx p = new Pnyx())
            {
                p.readString(PLANETS_GODS_TITANS);
                p.parseCsv();
                p.grep("u");                        // U needs to be present in any column
                actual = p.processToString();
            }

            Assert.Equal(PLANETS_GODS_TITANS, actual);
        }
Example #3
0
        public void lineFilter()
        {
            String actual;

            using (Pnyx p = new Pnyx())
            {
                p.readString(MAGNA_CARTA);
                p.grep("god", caseSensitive: false);
                actual = p.processToString();
            }

            const String expected = @"KNOW THAT BEFORE GOD, for the health of our soul and those of our ancestors and heirs, 
to the honour of God, the exaltation of the holy Church, and the better ordering of our";

            Assert.Equal(expected, actual);
        }
Example #4
0
        public void rowFilter()
        {
            String actual;

            using (Pnyx p = new Pnyx())
            {
                p.readString(PLANETS_GODS);
                p.parseCsv();
                p.grep("war");
                actual = p.processToString();
            }

            const String expected = "Ares,Mars,\"Hated god of war\"\r\n";

            Assert.Equal(expected, actual);
        }
Example #5
0
        public static int main()
        {
            using (Pnyx p = new Pnyx())
            {
                p.read(@"c:/dev/asclepius/prod_import/events.csv");
                p.grep("CL/C/MonitoringDashboard/");
                p.sed("MonitoringDashboard[/][^.]+[.]", "MonitoringDashboard.");
                p.sed("CL/C/MonitoringDashboard.", "");
                p.parseCsv();
                p.withColumns(p2 => { p2.sed(",", "", "g"); }, 2, 3);
                p.lineTransformerFunc(line => TextUtil.encodeSqlValue(line));
                p.print("insert into `groupit` values($1,$2);");
                p.write(@"c:/dev/asclepius/prod_import/events.sql");
            }

            return(0);
        }