Parse data with double spaces

Now, this is very easy to do. But at office spent some good time tackling this problem. The problem was–we had data as a text file from Oracle output, which somehow had double spaces as delimiters, and we got that very late. We had a SAS program, which used to read the file and that program was not working. Then we turned to Excel (of course), and within seconds we got a parsed file.
Here is the code for that.

Public Sub parse_file()
Application.ScreenUpdating = False
Dim i As Integer, j As Long, k As Long, no_of_rows As Long, storeVal, parsedVal
no_of_rows = Range(“A65536”).End(xlUp).Row
For i = 1 To no_of_rows
    storeVal = Range(“A” & i)
    parsedVal = Split(storeVal, ”  “)
    j = UBound(parsedVal)
    Range(Cells(i, 1), Cells(i, j + 1)) = parsedVal
Next i
Application.ScreenUpdating = True
MsgBox “Done”
End Sub

About the Author

A co-author of Data Science for Fundraising, an award winning keynote speaker, Ashutosh R. Nandeshwar is one of the few analytics professionals in the higher education industry who has developed analytical solutions for all stages of the student life cycle (from recruitment to giving). He enjoys speaking about the power of data, as well as ranting about data professionals who chase after “interesting” things. He earned his PhD/MS from West Virginia University and his BEng from Nagpur University, all in industrial engineering. Currently, he is leading the data science, reporting, and prospect development efforts at the University of Southern California.

>