OpenSeqReader
Opens a sequential CSV reader for import records one at a time.
Syntax
expression.OpenSeqReader
(configObj, [FilterColumns])
Parameters
Part | Description |
---|---|
configObj | Required. Identifier specifying a CSVparserConfig object variable. |
FilterColumns | Optional. Identifier specifying a ParamArray of Variant Type variable. |
Returns value
None
Behavior
The OpenSeqReader
method works in conjunction with the GetRecord
method. The configObj
parameter is an object with all the options considered by the parser during the import operation, see the ParseConfig Property documentation. The FilterColumns
parameter is used to retrieve only certain fields from each CSV/TSV record. Filters can be strings representing the names of the fields determined with the header record, or numbers representing the position of the requested field. If no filters are defined, all fields of the requested records will be retrieved. Each call to the OpenSeqReader
method will create a new conection to the CSV file.
📝Note
After opening a sequential reader, the user can read the CSV records one by one and implement logics to work with the extracted data. This makes it possible to mimic the more complex behavior of SQL statements.
☕Example
Private Sub OpenSeqReaderAndGetRecord()
Dim CSVint As CSVinterface
Dim csvRecord As CSVArrayList
Set CSVint = New CSVinterface
With CSVint
.parseConfig.path = Environ("USERPROFILE") & "\Desktop\Demo_100000records.csv"
Set .parseConfig.dialect = .SniffDelimiters(.parseConfig)
.OpenSeqReader .parseConfig, 1, 2 'Start sequential reader
'Import only 1st and 2nd fields
Do
Set csvRecord = .GetRecord 'Get a record from CSV file
Loop While Not csvRecord Is Nothing 'Loop trhonght all records in file
End With
Set CSVint = Nothing
End Sub