Class CSVFileInfo
Use these constants and service routines to simplify working with CSV type files.
Inheritance
Inherited Members
Namespace: WizardWrx
Assembly: WizardWrx.Common.dll
Syntax
public static class CSVFileInfo
Fields
| Improve this Doc View SourceEMPTY_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
| Improve this Doc View SourceFIRST_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
| Improve this Doc View SourceLABEL_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
Methods
| Improve this Doc View SourceLongRecordCount(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
| Improve this Doc View SourceRecordCount(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.