Parsing/sorting numbers help?

K

Keith (Southend)G

Help getting started...

I'm hoping someone can just show me what sort of VB code would be
required to do the following, I guess fairly simple task to an expert.
There are many more thing I will want to do
but given one single example I can build from, I feel I can make a
start. I just don't seem to be able to find any examples on-line that
would start me on my way. I think the 'If' and 'End If'
functions will be used, but I would just love to see what the coding
would look like to acheive the following and start me on my way, as I
seem to be getting bogged down atm.
I have some idea with the forms and opening bit in text boxes and
getting the result into a text box.


Before:
################################################################################
# SYNOPS from 03693, Shoeburyness (United Kingdom) | 51-33N | 000-50E
| 2 m
################################################################################
200912101150 AAXX 10124 03693 16975 /3011 10099 20060 30276 40279
51021 60001 91150
333 8//99=
200912100850 AAXX 10094 03693 46975 /2708 10078 20055 30255 40257
53029 90850
333 8//99=
200912100750 AAXX 10084 03693 46974 /2809 10076 20058 30244 40247
53027 90750
333 8//99=
200912100650 AAXX 10074 03693 46973 /2710 10082 20063 30232 40235
52022 90650
333 8//99=
200912100550 AAXX 10064 03693 16972 /2808 10089 20073 30226 40229
53021 69942 90550
333 20089 3/007 70004 8//99=

################################################################################
# SYNOPS from 03707, Chivenor (United Kingdom) | 51-05N | 004-09W | 8
m
################################################################################
200912101150 AAXX 10124 03707 15960 /0702 10104 20082 30298 40305
51016 60001 91150
333 8//99=
200912100850 AAXX 10094 03707 45561 /1002 10069 20061 30281 40289
52028 90850
333 83/26=
200912100750 AAXX 10084 03707 45562 /3003 10079 20062 30272 40279
53025 90750
333 86/24=
200912100650 AAXX 10074 03707 47557 /3004 10087 20072 3//// 4////
5//// 704// 90650
333 87/25=
200912100550 AAXX 10064 03707 17558 /2810 10091 20075 30253 40261
52018 60012 704// 90550
333 20090 3/007 70014 83/25=


After:
03693 16972 /2808 10089 20073 30226 40229 53021 69942 90550 333 20089
3/007 70004 8//99=
03707 17558 /2810 10091 20075 30253 40261 52018 60012 704// 90550 333
20090 3/007 70014 83/25=

This is just then displaying the AAXX 10064 numbers, the full dates
'200912100550' can be ignored.

My final idea is to be able to do loop which will then break all the
differnt times into seperate files, so in the case of the example
above I would have 5 files
containing 2 lines similar to above. 6hr, 7hr, 8hr, 9hr & 12 hr. But
this is the next step I will try to fathom out once I understand the
'parsing' techniques.

Any help would great.

Many thanks

Keith (Southend)
 
F

Family Tree Mike

Help getting started...

I'm hoping someone can just show me what sort of VB code would be
required to do the following, I guess fairly simple task to an expert.
There are many more thing I will want to do
but given one single example I can build from, I feel I can make a
start. I just don't seem to be able to find any examples on-line that
would start me on my way. I think the 'If' and 'End If'
functions will be used, but I would just love to see what the coding
would look like to acheive the following and start me on my way, as I
seem to be getting bogged down atm.
I have some idea with the forms and opening bit in text boxes and
getting the result into a text box.


Before:
################################################################################
# SYNOPS from 03693, Shoeburyness (United Kingdom) | 51-33N | 000-50E
| 2 m
################################################################################
200912101150 AAXX 10124 03693 16975 /3011 10099 20060 30276 40279
51021 60001 91150
333 8//99=
200912100850 AAXX 10094 03693 46975 /2708 10078 20055 30255 40257
53029 90850
333 8//99=
200912100750 AAXX 10084 03693 46974 /2809 10076 20058 30244 40247
53027 90750
333 8//99=
200912100650 AAXX 10074 03693 46973 /2710 10082 20063 30232 40235
52022 90650
333 8//99=
200912100550 AAXX 10064 03693 16972 /2808 10089 20073 30226 40229
53021 69942 90550
333 20089 3/007 70004 8//99=

################################################################################
# SYNOPS from 03707, Chivenor (United Kingdom) | 51-05N | 004-09W | 8
m
################################################################################
200912101150 AAXX 10124 03707 15960 /0702 10104 20082 30298 40305
51016 60001 91150
333 8//99=
200912100850 AAXX 10094 03707 45561 /1002 10069 20061 30281 40289
52028 90850
333 83/26=
200912100750 AAXX 10084 03707 45562 /3003 10079 20062 30272 40279
53025 90750
333 86/24=
200912100650 AAXX 10074 03707 47557 /3004 10087 20072 3//// 4////
5//// 704// 90650
333 87/25=
200912100550 AAXX 10064 03707 17558 /2810 10091 20075 30253 40261
52018 60012 704// 90550
333 20090 3/007 70014 83/25=


After:
03693 16972 /2808 10089 20073 30226 40229 53021 69942 90550 333 20089
3/007 70004 8//99=
03707 17558 /2810 10091 20075 30253 40261 52018 60012 704// 90550 333
20090 3/007 70014 83/25=

This is just then displaying the AAXX 10064 numbers, the full dates
'200912100550' can be ignored.

My final idea is to be able to do loop which will then break all the
differnt times into seperate files, so in the case of the example
above I would have 5 files
containing 2 lines similar to above. 6hr, 7hr, 8hr, 9hr& 12 hr. But
this is the next step I will try to fathom out once I understand the
'parsing' techniques.

Any help would great.

Many thanks

Keith (Southend)

You pretty much need to read the file line by line, building the string
that you need to parse first, as they are on multiple lines. To do
that, the code below should get you started:

dim observation as string
Using fs As New System.IO.FileStream _
("SomeFile.Dat", System.IO.FileMode.Open)

Dim sr As New System.IO.StreamReader(fs)
Dim input As String = sr.ReadLine()
While (input <> Nothing)

if (not input.StartsWith("#")) then
observation = observation & " " & input
endif

if (observation.EndsWith("=")) then
' parse the line here...

' set the current observation to blank to start a new run
observation = ""
end if

input = sr.ReadLine()
End While
End Using

Once you have the complete line that needs parsing, you should use the
String.Split() method. This can split the string into a set of words
representing the individual values in your input. Pull the values you
want from the array, and spit them out as desired.
 
K

Keith (Southend)G

You pretty much need to read the file line by line, building the string
that you need to parse first, as they are on multiple lines.  To do
that, the code below should get you started:

dim observation as string
Using fs As New System.IO.FileStream _
   ("SomeFile.Dat", System.IO.FileMode.Open)

   Dim sr As New System.IO.StreamReader(fs)
   Dim input As String = sr.ReadLine()
   While (input <> Nothing)

     if (not input.StartsWith("#")) then
       observation = observation & " " & input
     endif

     if (observation.EndsWith("=")) then
       ' parse the line here...

       ' set the current observation to blank to start a new run
       observation = ""
     end if

     input = sr.ReadLine()
   End While
End Using

Once you have the complete line that needs parsing, you should use the
String.Split() method.  This can split the string into a set of words
representing the individual values in your input.  Pull the values you
want from the array, and spit them out as desired.

Thank you Mike, that's gives me a starting point.

Keith (Southend)
 
Top