VBSCript GetCSVCollectionThis is a featured page

NOTE: This one is not as good as the VB6 one.

Function GetCSVCollection(ByVal vsFilePath)
'Returns a collection of collections.
'There's a collection for each row.
'The file is made by saving an Excel spreadsheet as a CSV file.
' Dim cEntries
' Set cEntries = GetCSVCollection("Entries.csv")
Dim asRows, asFieldNames, cRecordSet, i, asFieldValues
Dim cRecord, iFieldCount, j

asRows = Split(GetFileContents(vsFilePath), vbCrLf)
asFieldNames = Split(asRows(0), ",")
Set cRecordSet = CreateObject("Scripting.Dictionary")
For i = 1 To UBound(asRows)
asFieldValues = Split(asRows(i), ",")
Set cRecord = CreateObject("Scripting.Dictionary")
If UBound(asFieldNames) < UBound(asFieldValues) Then
iFieldCount = UBound(asFieldNames) + 1
Else
iFieldCount = UBound(asFieldValues) + 1
End If

For j = 0 To iFieldCount - 1
cRecord.Add Trim(asFieldNames(j)), asFieldValues(j)
Next
cRecordSet.add i - 1, cRecord
Next

Set GetCSVCollection = cRecordSet
End Function


No user avatar
2buck
Latest page update: made by 2buck , Dec 2 2006, 11:27 AM EST (about this update About This Update 2buck Edited by 2buck

11 words added

view changes

- complete history)
Keyword tags: None (edit keyword tags)
More Info: links to this page

Anonymous  (Get credit for your thread)


There are no threads for this page.  Be the first to start a new thread.