how can i get rid of white space and parse this info

i have a text file of Tmp.txt with the below info

-------------- tmp.txt file info --------------

drwxrw-rw-   1 user     group           0 Oct 18 16:03 DefaultPage
-rw-rw-rw-   1 user     group        3638 Jun  3  2001 favicon.ico
drwxrw-rw-   1 user     group           0 Oct 18 16:03 Gallary
-rw-rw-rw-   1 user     group        3027 Oct 18 01:52 index.htm
-rw-rw-rw-   1 user     group        3383 Oct 18 02:13 index_org.php
drwxrw-rw-   1 user     group           0 Oct 18 16:03 Jayna Tags
-rw-rw-rw-   1 user     group       11603 Oct 18 01:52 ledunder.gif
drwxrw-rw-   1 user     group           0 Nov  3 21:17 TD
drwxrw-rw-   1 user     group           0 Oct 18 16:03 WildcatZips

------------- end tmp.txt file info -----------
i want to pull the below info from it
dir permissions
file size
month
day
time
file name

ive tryed the below code it reads the lines fine but to get the info into a array i seam to be having problems

it seams that dir and files have diffrent info so ive checked for that via first chr d id for dir and - is for file
but it seams the array fields are really messed up in the below example the dirs work fine its the files im having problems with
i think its due to whitespace so if i compress the info and make it read one space between fields i think it will work ok.
i tryed to do that with the sep area but it seams to not be working any ideas???

thx
Johnny
aka Pern

----------code --------------
       If System.IO.File.Exists("Tmp.txt") Then
            ''MsgBox("Exists!")
            Dim File As IO.StreamReader = IO.File.OpenText("Tmp.txt")
            Dim lines() As String = Split(File.ReadToEnd(), ControlChars.CrLf) 'split it up via the new line chars (Cr & Lf)
            File.Close()
            'Dim myArray(24) As String
            Dim intArray As Integer
            Dim File_Icon, File_IconTxt, File_Permissions_Txt As String
            Dim dir_perm, file_size, file_month, file_day, file_time, file_name As String
            intArray = 0
            Do While intArray < UBound(lines) - 1
                Dim myString As String = lines(intArray)
                Dim seperators() As Char = {" "c, Chr(10), Chr(13), vbTab}
                Dim myArray() As String = myString.Split(seperators)
                intArray = intArray + 1
                ''Label4.Text = Input(1, 1)
                '* 0 - dir permissions - 0
                '* 20 - file size - 16
                '* 21 - month - 17
                '* 22 - day - 18
                '* 23 - time - 19
                '* 24 - file name - 20
                File_Permissions_Txt = Mid(myArray(0), 1, 1)
                Select Case File_Permissions_Txt
                    Case "d"
                        ''dir
                        'dir_perm, file_size, file_month, file_day, file_time, file_name
                        ''dir_perm = myArray(0)
                        file_size = myArray(20)
                        file_month = myArray(21)
                        file_day = myArray(22)
                        file_time = myArray(23)
                        file_name = myArray(24)
                    Case "-"
                        ''file
                        'dir_perm, file_size, file_month, file_day, file_time, file_name
                        ''dir_perm = myArray(0)
                        file_size = myArray(16)
                        file_month = myArray(17)
                        file_day = myArray(18)
                        file_time = myArray(19)
                        file_name = myArray(20)
                    Case "l"
                        File_Icon = "Link"
                End Select
                '            
loop
end if
-------------------- end code ------------------
JohnnyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

arif_eqbalCommented:
Hi Pern

I tried to analyze your Log File but there are certain discrepancies there, which is making it difficult to develop a robust code for parsing the file. I think that's why you are having some problems as well.

For eg. the 2nd line of your file does not contain any Time at all

-rw-rw-rw-   1 user     group        3638 Jun  3  2001 favicon.ico

here we have the Year (2001) instead, Now this yesr is not there in any other line

Again if you look at the line

drwxrw-rw-   1 user     group           0 Oct 18 16:03 Jayna Tags

There's a space between Jayna & tags

So you see if you can not depend upon Space to act as separator as 2001 will be picked up as Time then
Also if you get a string like
-rw-rw-rw-   1 user     group        3638 Jun  3  2001 Jayna Tags
worst still,
So what I feel is you should look for more log files and try to decipher a clear pattern (strike out a few exceptions that might oocuur due to some Error in generating this log)

Also I saw your earlier post where you wanted this to be displayed in HTML, so in that case you might avoid separating the values in a line and just get the File permission stuff and work on it...

0
Arthur_WoodCommented:
here is some VB 6 code (which should work essentially as is in .NET):
this will parse the ENTIRE string into ALL of its componets, you can then use the ones that you need.


Private Sub cmdParse_Click()
Dim args() As String
Dim iCol As Integer
If Len(txtSource.Text) > 0 Then
    args = Split(txtSource.Text, " ")
    txtPermissions.Text = args(0)
    iCol = 1
    Do While args(iCol) = ""
        iCol = iCol + 1
    Loop
   
    txtType.Text = args(iCol)
    iCol = iCol + 1
    Do While args(iCol) = ""
        iCol = iCol + 1
    Loop
   
    txtUser.Text = args(iCol)
    iCol = iCol + 1
    Do While args(iCol) = ""
        iCol = iCol + 1
    Loop
   
    txtGroup.Text = args(iCol)
    iCol = iCol + 1
    Do While args(iCol) = ""
        iCol = iCol + 1
    Loop
   
    txtSize.Text = args(iCol)
    iCol = iCol + 1
    Do While args(iCol) = ""
        iCol = iCol + 1
    Loop
   
    txtMonth.Text = args(iCol)
    iCol = iCol + 1
    Do While args(iCol) = ""
        iCol = iCol + 1
    Loop
   
    txtDay.Text = args(iCol)
    iCol = iCol + 1
    Do While args(iCol) = ""
        iCol = iCol + 1
    Loop
   
    txtTime.Text = args(iCol)
    iCol = iCol + 1
    Do While args(iCol) = ""
        iCol = iCol + 1
    Loop
   
    txtName.Text = args(iCol)
   
End If
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JohnnyAuthor Commented:
Arthur_Wood,

absolutly fantastic it works great

dang ive been banging my head about this


how it works id be interested in knowing...

BUT IT WORKS !!!!!!!!!!!!! yipppppeeee

thx
Johnny
aka Pern
0
Arthur_WoodCommented:
the split function breaks up the string into pieces, using a sincle balnk ' ' as the separator.  where there are multiple blanks, you get '' (a zero length string) for each of the multiple blanks.  The loops are there to skipp the '' entries in the resulting array created by the Split Function - look up the Split function in the VB.NET help system.

AW
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.