Table of Contents

Class SunamoCsvReader

Namespace
SunamoCsv
Assembly
SunamoCsv.dll

Používat CsvFile místo toho Class to read csv content from various sources Downloaded from http://www.codeproject.com/Articles/86973/C-CSV-Reader-and-Writer

public sealed class SunamoCsvReader : IDisposable
Inheritance
SunamoCsvReader
Implements
Inherited Members
Extension Methods

Constructors

SunamoCsvReader(Stream)

Initialises the reader to work from an existing stream

public SunamoCsvReader(Stream stream)

Parameters

stream Stream

Stream

SunamoCsvReader(Stream, Encoding?)

Initialises the reader to work from an existing stream

public SunamoCsvReader(Stream stream, Encoding? encoding)

Parameters

stream Stream

Stream

encoding Encoding

Encoding (null for UTF8)

SunamoCsvReader(string)

Initialises the reader to work from a file

public SunamoCsvReader(string filePath)

Parameters

filePath string

File path

SunamoCsvReader(string, Encoding?)

Initialises the reader to work from a file

public SunamoCsvReader(string filePath, Encoding? encoding)

Parameters

filePath string

File path

encoding Encoding

Encoding (null for UTF8)

SunamoCsvReader(Encoding?, string)

Initialises the reader to work from a csv string

public SunamoCsvReader(Encoding? encoding, string csvContent)

Parameters

encoding Encoding

Text encoding to use

csvContent string

CSV content as string

Properties

Delimiter

Gets or sets the delimiter character used to separate fields in CSV files (default: comma)

public static char Delimiter { get; set; }

Property Value

char

FieldCount

Gets the field count or returns null if no fields have been read

public int? FieldCount { get; }

Property Value

int?

Fields

Returns a collection of fields or null if no record has been read

public List<string>? Fields { get; }

Property Value

List<string>

HasHeaderRow

Gets or sets whether the csv file has a header row

public bool HasHeaderRow { get; set; }

Property Value

bool

TrimColumns

Gets or sets whether column values should be trimmed

public bool TrimColumns { get; set; }

Property Value

bool

Methods

DateTime(CsvFile, int)

Use CsvFile.DateTimes instead

public static List<DateTime?> DateTime(CsvFile file, int columnIndex)

Parameters

file CsvFile

CsvFile instance

columnIndex int

Zero-based column index

Returns

List<DateTime?>

Dispose()

Disposes of all unmanaged resources

public void Dispose()

ReadIntoDataTable()

Reads a csv file format into a data table. This method will always assume that the table has a header row as this will be used to determine the columns.

public DataTable ReadIntoDataTable()

Returns

DataTable

ReadIntoDataTable(Type[])

Reads a csv file format into a data table. This method will always assume that the table has a header row as this will be used to determine the columns.

public DataTable ReadIntoDataTable(Type[] columnTypes)

Parameters

columnTypes Type[]

Array of column types

Returns

DataTable

ReadNextRecord()

Reads the next record

public bool ReadNextRecord()

Returns

bool

True if a record was successfuly read, otherwise false

Strings(CsvFile, int)

Returns string values from specified column (use CsvFile.Strings instead)

public static List<string> Strings(CsvFile file, int columnIndex)

Parameters

file CsvFile

CsvFile instance

columnIndex int

Zero-based column index

Returns

List<string>

List of string values from the column