Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
set objFile = objFSO.OpenTextFile("data.txt", 1)
strDelimiter = ","
arrLongest = array(0,0,0,0,0,0) 'number of elements equals number of colums
do while not objFile.AtEndOfStream
'1. Read each row
strRow = objFile.ReadLine
'2. Split the row into an array using the delimiter
arrRow = split(strLine, strDelimiter)
for i = 0 to ubound(arrRow) - 1
'3. Get the length of each value in the array
intLength = len(arrRow(i))
'4. Compare it's length with the previous max length
if (intValue > arrLongest(i)) then
'5. If it's longer, it because the new max length
arrLongest(i) = intLength
end if
next
loop
'Print the longest values for each column
msgbox join(arrLongest, ", ")
Option Explicit
Dim Conn, rs, sql
Set Conn = CreateObject("ADODB.Connection") 'Server.
Conn.Open _
"Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"DBQ=C:\PathToCSVFile" & _
";Extensions=asc,csv,tab,txt;HDR=YES;Persist Security Info=False;"
sql = "SELECT " & _
" MAX(Len([LAST_NAME])) As MaxLast, " & _
" MAX(Len([FIRST_NAME])) As MaxFirst " & _
" FROM mycsvfile.csv"
Set rs = CreateObject("ADODB.Recordset")
rs.Open sql, Conn
Wscript.echo "Longest last name is: " & rs("MaxLast") & ""
Wscript.echo "Longest first name is: " & rs("MaxFirst") & ""
rs.Close