@@ -25,7 +25,7 @@ Sub ImportRecords_RFC4180()
2525 Set CSVix = New CSVinterface 'Create new instance
2626 Call CSVix.OpenConnection(filePath) 'Open a physical connection to the CSV file
2727 Call CSVix.ImportFromCSV 'Import data
28- Call CSVix(MyArray) 'Dumps the data to array
28+ Call CSVix.DumpToArray (MyArray) 'Dumps the data to array
2929 Set CSVix = Nothing 'Terminate the current instance
3030End Sub
3131```
@@ -51,7 +51,7 @@ Sub ImportTopTenRecords_RFC4180()
5151 CSVix.EndingRecord = 10 'Sets the importation ending
5252 Call CSVix.OpenConnection(filePath) 'Open a physical connection to the CSV file
5353 Call CSVix.ImportFromCSV 'Import the range of records
54- Call CSVix(MyArray) 'Dumps the data to array
54+ Call CSVix.DumpToArray (MyArray) 'Dumps the data to array
5555 Set CSVix = Nothing 'Terminate the current instance
5656End Sub
5757```
@@ -74,7 +74,7 @@ Sub ImportTopTenRecords_RFC4180()
7474 tmpCSV = CSVix.GetDataFromCSV(filePath) 'Store CSV file's content.
7575 CSVix.EndingRecord = 10 'Sets the importation ending
7676 Call CSVix.ImportFromCSVString(tmpCSV, HeadersOmission:= True ) 'Import the range of records omitting the headers
77- Call CSVix(MyArray) 'Dumps the data to array
77+ Call CSVix.DumpToArray (MyArray) 'Dumps the data to array
7878 Set CSVix = Nothing 'Terminate the current instance
7979End Sub
8080```
@@ -100,7 +100,7 @@ Sub ImportTenMiddleRecords_RFC4180()
100100 CSVix.StartingRecord = 11 'Sets the importation ending
101101 CSVix.EndingRecord = 20 'Sets the importation ending
102102 Call CSVix.ImportFromCSVString(tmpCSV, HeadersOmission:= True ) 'Import the range of records omitting the headers
103- Call CSVix(MyArray) 'Dumps the data to array
103+ Call CSVix.DumpToArray (MyArray) 'Dumps the data to array
104104 Set CSVix = Nothing 'Terminate the current instance
105105End Sub
106106```
@@ -131,7 +131,7 @@ Sub ImportRecords()
131131 CSVix.QuotingMode = QuotationMode.All 'Alter behavior for escaped files
132132 CSVix.EscapeToken = EscapeTokens.NullChar 'Specify that CSV file has neither field needing to be escaped.
133133 Call CSVix.ImportFromCSV 'Import data
134- Call CSVix(MyArray) 'Dumps the data to array
134+ Call CSVix.DumpToArray (MyArray) 'Dumps the data to array
135135 Set CSVix = Nothing 'Terminate the current instance
136136End Sub
137137```
@@ -141,7 +141,7 @@ The \[EXAMPLE6\] shows how you can dump the imported data to an Excel Worksheet.
141141Sub ImportRecords_RFC4180()
142142 Dim CSVix As CSVinterface
143143 Dim filePath As String
144-
144+
145145 filePath = "C:\Demo_Headed_400k_records.csv" 'Change this to suit your needs
146146 Set CSVix = New CSVinterface 'Create new instance
147147 Call CSVix.OpenConnection(filePath) 'Open a physical connection to the CSV file
@@ -172,7 +172,72 @@ Sub ImportRecords()
172172 CSVix.QuotingMode = QuotationMode.All 'Alter behavior for escaped files
173173 CSVix.EscapeToken = EscapeTokens.DoubleQuotes 'Specify that all fields need to be escaped.
174174 Call CSVix.ImportFromCSV 'Import data
175- Call CSVix(MyArray) 'Dumps the data to array
175+ Call CSVix.DumpToArray(MyArray) 'Dumps the data to array
176+ Set CSVix = Nothing 'Terminate the current instance
177+ End Sub
178+ ```
179+
180+ The \[ EXAMPLE8\] shows how you can loop through all the CSV imported data from the current VBA-CSV interface class instance.
181+
182+ See also
183+ : [ VectorsBound property] ( https://ws-garcia.github.io/VBA-CSV-interface/api/properties/vectorsbound.html ) , [ RectangularResults property] ( https://ws-garcia.github.io/VBA-CSV-interface/api/properties/rectangularresults.html ) .
184+
185+ ``` vb
186+ Sub LoopThroughImportedRecords()
187+ Dim CSVix As CSVinterface
188+ Dim MyArray() As String
189+ Dim filePath As String
190+
191+ filePath = "C:\Demo_Headed_400k_records.csv" 'Change this to suit your needs
192+ Set CSVix = New CSVinterface 'Create new instance
193+ Call CSVix.OpenConnection(filePath) 'Open a physical connection to the CSV file
194+ Call CSVix.ImportFromCSV 'Import data
195+ '@--------------------------------------------------------------------
196+ ' Loop through imported data. SAVE TO 2-DIMENSIONAL ARRAY.
197+ Dim WGstrArray() As String , vCollection As Collection
198+ Dim i As Long , j As Long , k As Long
199+ Dim CurJaggedIndex As Long , CurJaggedSize As Long
200+ Dim JaggedCounter As Long , WGvarArray() As Variant
201+
202+ If CSVix.RectangularResults Then 'The internal array is rectangular
203+ ReDim WGstrArray( 0 To CSVix.Count - 1 , 0 To CSVix.VectorsBound)
204+ Else
205+ ReDim WGstrArray( 0 To CSVix.Count - 1 , 0 To CSVix.VectorsMaxBound)
206+ Set vCollection = CSVix.IrregularVectors
207+ JaggedCounter = 1
208+ CurJaggedIndex = vCollection.Item(JaggedCounter)( 0 )
209+ CurJaggedSize = vCollection.Item(JaggedCounter)( 1 )
210+ End If
211+ 'Access Items one by one
212+ For i = 0 To UBound(WGstrArray)
213+ For j = 0 To CSVix.VectorsBound
214+ WGstrArray(i, j) = CSVix.Item(i, j)
215+ Next j
216+ If Not CSVix.RectangularResults Then
217+ If i = CurJaggedIndex Then
218+ k = j
219+ Do
220+ WGstrArray(i, k) = CSVix.Item(i, k)
221+ k = k + 1
222+ Loop While k <= CurJaggedSize
223+ JaggedCounter = JaggedCounter + 1
224+ If JaggedCounter <= vCollection.Count Then
225+ CurJaggedIndex = vCollection.Item(JaggedCounter)( 0 )
226+ CurJaggedSize = vCollection.Item(JaggedCounter)( 1 )
227+ End If
228+ End If
229+ End If
230+ Next i
231+ If CSVix.ErrNumber <> 0 Then Debug.Print "#Error:" ; CSVix.ErrNumber, "Desc.:" ; CSVix.ErrDescription
232+ '@--------------------------------------------------------------------
233+ ' Loop through imported data. SAVE TO JAGGED ARRAY.
234+ 'Redim the array
235+ ReDim WGvarArray( 0 To CSVix.Count - 1 )
236+ For i = 0 To UBound(WGvarArray)
237+ For j = 0 To CSVix.VectorsBound
238+ WGvarArray(i) = CSVix.Item(i)
239+ Next j
240+ Next i
176241 Set CSVix = Nothing 'Terminate the current instance
177242End Sub
178243```
0 commit comments