Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Dim fso : Set fso = CreateObject("Scripting.FileSystemObject")
  2. Dim OutputHTML : Set OutputHTML = fso.CreateTextFile("C:\Users\jmwal\Desktop\data.html")
  3. Dim file : Set file = fso.OpenTextFile("C:\Users\jmwal\Desktop\data.txt", 1, True)
  4. Dim fc : fc = file.ReadAll : file.close : Dim fcArray : fcArray = Split(fc, vbCrLf)
  5.  
  6. REM Rebuild Array
  7.  
  8. Dim opArray() : ReDim opArray(0)
  9. For Each row In fcArray
  10.     Dim tmp: tmp = Split(row, "|")
  11.     For ent=0 To UBound(tmp)
  12.         If ent  > UBound(opArray) Then
  13.             ReDim Preserve opArray(UBound(opArray)+1)
  14.             opArray(ent) = Trim(tmp(ent))
  15.         Else
  16.             If Len(opArray(ent)) > 0 Then
  17.                 'OutputHTML.WriteLine "<tr>"
  18.                opArray(ent) = opArray(ent) & " " & Trim(tmp(ent))
  19.               '  OutputHTML.WriteLine "</tr>"
  20.            Else
  21.                 opArray(ent) = Trim(tmp(ent))
  22.             End If
  23.         End If
  24.     Next
  25. Next
  26.  
  27. REM Echo
  28. 'WScript.echo Join(opArray, vbCrLf)
  29.  
  30. REM What does opArray look like
  31. 'For Each item in opArray
  32.    'WScript.echo item
  33. 'Next
  34.  
  35.  
  36. REM report opArray in HTML
  37.  
  38. OutputHTML.WriteLine "<html>"
  39. OutputHTML.Writeline "<body>"
  40. OutputHTML.WriteLine "<table BORDER=1>"
  41.  
  42. For Each row in opArray
  43.     OutputHTML.WriteLine "<tr>"
  44.     For Each col in Split(row, " ")
  45.         OutputHTML.Write "<td>" + col + "</td>"
  46.     Next
  47.     OutputHTML.WriteLine "</tr>"      
  48. Next
  49.  
  50. OutputHTML.WriteLine "</table>"
  51. OutputHTML.WriteLine "</body>"
  52. OutputHTML.WriteLine "</html>"
  53. OutputHTML.Close
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement