shimAnd
method. An example
of both are shown below.const String input = @"Line one,a,,c Line two,a,b,c Line three,,,c "; using (Pnyx p = new Pnyx()) { p.readString(input); p.parseCsv(); p.hasLine(); p.writeStdout(); } // outputs: // "Line one",a,,c // "Line two",a,b,c // "Line three",,,c
const String input = @"Line one,a,,c Line two,a,b,c Line three,,,c "; using (Pnyx p = new Pnyx()) { p.readString(input); p.parseCsv(); p.shimAnd(p2 => p2.hasLine()); p.writeStdout(); } // outputs: // "Line two",a,b,c
Pnyx
supports using Lambda expression for
quicker, more flexible usage. The following examples shows the two Row operations with Lambda expressions.const String input = @"Line one,KEEPER Line two,Loser "; using (Pnyx p = new Pnyx()) { p.readString(input); p.parseCsv(); p.rowFilterFunc(x => TextUtil.isUpperCase(x[1])); p.writeStdout(); } // outputs: // "Line one",KEEPER
const String input = @"Line one,KEEPER Line two,LOSER "; using (Pnyx p = new Pnyx()) { p.readString(input); p.parseCsv(); p.rowTransformerFunc(x => new List<string> {NameUtil.toTitleCase(x[1])}); p.writeStdout(); } // outputs: // Keeper // Loser
IRowConverter
should be implemented and used with rowToLine method. Below are some examples of converting Row data to Line data.const String input = "Socialism,Communism,Fascism"; using (Pnyx p = new Pnyx()) { p.readString(input); p.parseCsv(); p.print("Failed Systems: $1, $2, and $3"); p.writeStdout(); } // outputs: Failed Systems: Socialism, Communism, and Fascism
const String input = "col1,\"Column, zwei\""; using (Pnyx p = new Pnyx()) { p.readString(input); p.parseCsv(); p.printDelimiter("|"); p.writeStdout(); } // outputs: col1|Column, zwei