Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public List <String> lineToRow(String source)
 {
     return(CsvUtil.parseRow(source, settings.delimiter, settings.escapeChar,
                             settings.allowStrayQuotes, settings.allowTextAfterClosingQuote, settings.terminateQuoteOnEndOfFile, settings.allowUnquotedNewlines,
                             stringBuilder
                             ));
 }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 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);
 }
Esempio n. 6
0
        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;
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
 public void writeRow(IEnumerable <String> row)
 {
     CsvUtil.writeRow(writer, row, delimiter, escapeChar, charsNeedEscape);
     writer.WriteLine();
 }
Esempio n. 9
0
 public String rowToLine(List <String> source)
 {
     return(CsvUtil.rowToString(source, settings.delimiter, settings.escapeChar, settings.charsNeedEscape));
 }