public CsvSettings setDefaults( bool?strict = null, char?delimiter = null, char?escapeChar = null, char[] charsNeedEscape = null ) { if (strict.HasValue) { this.strict = strict.Value; } if (delimiter.HasValue) { this.delimiter = delimiter.Value; } if (escapeChar.HasValue) { this.escapeChar = escapeChar.Value; } if (charsNeedEscape != null) { this.charsNeedEscape = CsvUtil.createCharsNeedEscape(this.delimiter, this.escapeChar, charsNeedEscape); } else if (delimiter.HasValue || escapeChar.HasValue) { this.charsNeedEscape = CsvUtil.createCharsNeedEscape(this.delimiter, this.escapeChar, this.charsNeedEscape); } return(this); }
public List <String> lineToRow(String source) { return(CsvUtil.parseRow(source, settings.delimiter, settings.escapeChar, settings.allowStrayQuotes, settings.allowTextAfterClosingQuote, settings.terminateQuoteOnEndOfFile, settings.allowUnquotedNewlines, stringBuilder )); }
public CsvSettings(bool strict = true, char?delimiter = null, char?escapeChar = null, char[] charsNeedEscape = null) { this.strict = strict; this.delimiter = delimiter ?? CsvUtil.DEFAULT_DELIMITER; this.escapeChar = escapeChar ?? CsvUtil.DEFAULT_ESCAPE_CHAR; this.charsNeedEscape = CsvUtil.createCharsNeedEscape(this.delimiter, this.escapeChar, charsNeedEscape); }
public CsvWriter( TextWriter writer, char?delimiter = null, char?escapeChar = null ) { this.writer = writer; this.delimiter = delimiter ?? Settings.DEFAULT_CSV_DELIMITER; this.escapeChar = escapeChar ?? Settings.DEFAULT_CSV_ESCAPE_CHAR; charsNeedEscape = CsvUtil.createCharsNeedEscape(this.delimiter, this.escapeChar); }
public CsvWriter( Stream stream, Encoding defaultEncoding = null, char?delimiter = null, char?escapeChar = null ) { defaultEncoding = defaultEncoding ?? Settings.DEFAULT_ENCODING; writer = new StreamWriter(stream, defaultEncoding); this.delimiter = delimiter ?? Settings.DEFAULT_CSV_DELIMITER; this.escapeChar = escapeChar ?? Settings.DEFAULT_CSV_ESCAPE_CHAR; charsNeedEscape = CsvUtil.createCharsNeedEscape(this.delimiter, this.escapeChar); }
public void processRow(List <String> row) { if (previousRow != null) { CsvUtil.writeRow(writer, previousRow, settings.delimiter, settings.escapeChar, settings.charsNeedEscape); writer.Write(streamInformation.getOutputNewline()); } else { writer = new StreamWriter(stream, streamInformation.getOutputEncoding()); } previousRow = row; }
public void endOfFile() { if (previousRow != null) { CsvUtil.writeRow(writer, previousRow, settings.delimiter, settings.escapeChar, settings.charsNeedEscape); if (streamInformation.endsWithNewLine) { writer.Write(streamInformation.getOutputNewline()); } } else { writer = new StreamWriter(stream, streamInformation.getOutputEncoding()); } previousRow = null; writer.Flush(); }
public void writeRow(IEnumerable <String> row) { CsvUtil.writeRow(writer, row, delimiter, escapeChar, charsNeedEscape); writer.WriteLine(); }
public String rowToLine(List <String> source) { return(CsvUtil.rowToString(source, settings.delimiter, settings.escapeChar, settings.charsNeedEscape)); }