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
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
Categories: Uncategorized
![[CiteULike]](http://nandeshwar.info/wp-content/plugins/bookmarkify/citeulike.png)
![[del.icio.us]](http://nandeshwar.info/wp-content/plugins/bookmarkify/delicious.png)
![[Digg]](http://nandeshwar.info/wp-content/plugins/bookmarkify/digg.png)
![[Facebook]](http://nandeshwar.info/wp-content/plugins/bookmarkify/facebook.png)
![[Furl]](http://nandeshwar.info/wp-content/plugins/bookmarkify/furl.png)
![[Google]](http://nandeshwar.info/wp-content/plugins/bookmarkify/google.png)
![[Reddit]](http://nandeshwar.info/wp-content/plugins/bookmarkify/reddit.png)
![[Slashdot]](http://nandeshwar.info/wp-content/plugins/bookmarkify/slashdot.png)
![[StumbleUpon]](http://nandeshwar.info/wp-content/plugins/bookmarkify/stumbleupon.png)
![[Technorati]](http://nandeshwar.info/wp-content/plugins/bookmarkify/technorati.png)
![[Twitter]](http://nandeshwar.info/wp-content/plugins/bookmarkify/twitter.png)
![[Email]](http://nandeshwar.info/wp-content/plugins/bookmarkify/email.png)
Recent Comments