Regarding performance remember EXCEL is a SPREADSHEET, not a database.
It allows non programmers to do programming type things. Mixing code and the excel program itself is rarely elegent.
All this is vbscript but vbscript works in VBA but can be made faster by not using createobject.
It depends on how you are processing the data. If it's linear then this is easy
Set fso = CreateObject("Scripting.FileSystemObject")
Set srcfile = fso.GetFile(objArgs(0))
If err.number = 0 then Set TS = srcFile.OpenAsTextStream(1, 0)
Src()=Split(Repace(ts.readall, VBCR, ""), VBLF)
For Each Line in Src()
Field() = Split(Line, ",")
msgbox Field(0) & Field(1)
Next
But that uses memory if your data is large, this only reads a line at a time.
Do Until srcfile.AtEndOfStream
Line=srcfile.readline
Field() = Split(Line, ",")
msgbox Field(0) & Field(1)
Loop
More powerfull than arrays are Dictionaries and Recordsets. Recordsets can be made in memory, but as CSV are database files ADO can read them and return than as a recordset (which you can save). Here's a sample from MS's web site on how to use ADO to query and get one and another by me on how to make your own.
https://msdn.microsoft.com/en-us/library/ms974559.aspx?f=255&MSPPError=-2147217396
On Error Resume Next
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = &H0001
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
strPathtoTextFile = "C:\Databases\"
objConnection.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & strPathtoTextFile & ";" & _
"Extended Properties=""text;HDR=YES;FMT=Delimited"""
objRecordset.Open "SELECT * FROM PhoneList.csv", _
objConnection, adOpenStatic, adLockOptimistic, adCmdText
Do Until objRecordset.EOF
Wscript.Echo "Name: " & objRecordset.Fields.Item("Name")
Wscript.Echo "Department: " & _
objRecordset.Fields.Item("Department")
Wscript.Echo "Extension: " & objRecordset.Fields.Item("Extension")
objRecordset.MoveNext
Loop
Make your own
Sub Swap
Dim LineCount
Set rs = CreateObject("ADODB.Recordset")
With rs
.Fields.Append "LineNumber", 4
.Fields.Append "Txt", 201, 5000
.Open
LineCount = 0
Do Until Inp.AtEndOfStream
LineCount = LineCount + 1
.AddNew
.Fields("LineNumber").value = LineCount
.Fields("Txt").value = Inp.readline
.UpDate
Loop
.Sort = "LineNumber DESC"
Do While not .EOF
Outp.writeline .Fields("Txt").Value
.MoveNext
Loop
End With
End Sub