Show / Hide Table of Contents

Class CSVFileInfo

Use these constants and service routines to simplify working with CSV type files.

Inheritance
System.Object
CSVFileInfo
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: WizardWrx
Assembly: WizardWrx.Common.dll
Syntax
public static class CSVFileInfo

Fields

| Improve this Doc View Source

EMPTY_FILE

The Length property of a file returns this value to indicate that a file is absolutely empty.

Declaration
public const int EMPTY_FILE = 0
Field Value
Type Description
System.Int32
See Also
FIRST_RECORD
LABEL_ROW
RecordCount(String[])
LongRecordCount(String[])
LIST_IS_EMPTY
| Improve this Doc View Source

FIRST_RECORD

When you use Syatem.IO.File.ReadAllLines to read an entire file into an array of strings, this constant refers to the first data row of a labeled CSV file.

Declaration
public const int FIRST_RECORD = 1
Field Value
Type Description
System.Int32
See Also
EMPTY_FILE
LABEL_ROW
RecordCount(String[])
LongRecordCount(String[])
ARRAY_SECOND_ELEMENT
| Improve this Doc View Source

LABEL_ROW

When you use Syatem.IO.File.ReadAllLines to read an entire file into an array of strings, this constant refers to the label row of a labeled CSV file.

Declaration
public const int LABEL_ROW = 0
Field Value
Type Description
System.Int32
See Also
EMPTY_FILE
FIRST_RECORD
RecordCount(String[])
LongRecordCount(String[])
ARRAY_FIRST_ELEMENT

Methods

| Improve this Doc View Source

LongRecordCount(String[])

Derive the record count from the length of an array of records loaded from a labeled CSV type file.

Declaration
public static long LongRecordCount(string[] pastrWholeFile)
Parameters
Type Name Description
System.String[] pastrWholeFile

Array populated with all records read from a text file

Please see the Remarks section.

Returns
Type Description
System.Int64

Number of records in file, excluding the expected label row

Please see the Remarks section.

Remarks

This method starts from the LongLength property of array pastrWholeFile.

For the most part, this function is syntactic sugar. Given an array, pastrWholeFile, populated with strings that represent every record in a text file, this function returns the record count, adjusted for the label row that is assumed to be present.

This assumption is justified by the fact that I almost always put a label row in my delimited ASCII text files, even if the intended use doesn't require one, because it makes diagnostic studies so much easier. In the long run, I prefer to have my programs discard the unneeded label row than have a carbon unit try to figure out what is supposed to be in each of its columns.

See Also
EMPTY_FILE
FIRST_RECORD
LABEL_ROW
RecordCount(String[])
| Improve this Doc View Source

RecordCount(String[])

Derive the record count from the length of an array of records loaded from a labeled CSV type file.

Declaration
public static int RecordCount(string[] pastrWholeFile)
Parameters
Type Name Description
System.String[] pastrWholeFile

Array populated with all records read from a text file

Please see the Remarks section.

Returns
Type Description
System.Int32

Number of records in file, excluding the expected label row

Please see the Remarks section.

Remarks

This method starts from the Length property of array pastrWholeFile.

For the most part, this function is syntactic sugar. Given an array, pastrWholeFile, populated with strings that represent every record in a text file, this function returns the record count, adjusted for the label row that is assumed to be present.

This assumption is justified by the fact that I almost always put a label row in my delimited ASCII text files, even if the intended use doesn't require one, because it makes diagnostic studies so much easier. In the long run, I prefer to have my programs discard the unneeded label row than have a carbon unit try to figure out what is supposed to be in each of its columns.

See Also
EMPTY_FILE
FIRST_RECORD
LABEL_ROW
LongRecordCount(String[])

See Also

ArrayInfo
ListInfo
MagicNumbers
  • Improve this Doc
  • View Source
Back to top Generated by DocFX