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)
|
|
0
|
|
|
|
Reply
|
Keith
|
12/10/2009 1:31:47 PM |
|
On 12/10/2009 8:31 AM, Keith (Southend)G wrote:
> 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.
--
Mike
|
|
0
|
|
|
|
Reply
|
Family
|
12/11/2009 12:13:43 AM
|
|
On 11 Dec, 00:13, Family Tree Mike <FamilyTreeM...@ThisOldHouse.com>
wrote:
> On 12/10/2009 8:31 AM, Keith (Southend)G wrote:
>
>
>
>
>
> > 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
> > =A0 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:
> > #######################################################################=
####=AD#####
> > # =A0SYNOPS from 03693, Shoeburyness (United Kingdom) | 51-33N | 000-50=
E
> > | 2 m
> > #######################################################################=
####=AD#####
> > 200912101150 AAXX 10124 03693 16975 /3011 10099 20060 30276 40279
> > 51021 60001 91150
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 333 8//99=3D
> > 200912100850 AAXX 10094 03693 46975 /2708 10078 20055 30255 40257
> > 53029 90850
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 333 8//99=3D
> > 200912100750 AAXX 10084 03693 46974 /2809 10076 20058 30244 40247
> > 53027 90750
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 333 8//99=3D
> > 200912100650 AAXX 10074 03693 46973 /2710 10082 20063 30232 40235
> > 52022 90650
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 333 8//99=3D
> > 200912100550 AAXX 10064 03693 16972 /2808 10089 20073 30226 40229
> > 53021 69942 90550
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 333 20089 3/007 70004 8//99=3D
>
> > #######################################################################=
####=AD#####
> > # =A0SYNOPS from 03707, Chivenor (United Kingdom) | 51-05N | 004-09W | =
8
> > m
> > #######################################################################=
####=AD#####
> > 200912101150 AAXX 10124 03707 15960 /0702 10104 20082 30298 40305
> > 51016 60001 91150
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 333 8//99=3D
> > 200912100850 AAXX 10094 03707 45561 /1002 10069 20061 30281 40289
> > 52028 90850
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 333 83/26=3D
> > 200912100750 AAXX 10084 03707 45562 /3003 10079 20062 30272 40279
> > 53025 90750
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 333 86/24=3D
> > 200912100650 AAXX 10074 03707 47557 /3004 10087 20072 3//// 4////
> > 5//// 704// 90650
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 333 87/25=3D
> > 200912100550 AAXX 10064 03707 17558 /2810 10091 20075 30253 40261
> > 52018 60012 704// 90550
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 333 20090 3/007 70014 83/25=3D
>
> > After:
> > 03693 16972 /2808 10089 20073 30226 40229 53021 69942 90550 333 20089
> > 3/007 70004 8//99=3D
> > 03707 17558 /2810 10091 20075 30253 40261 52018 60012 704// 90550 333
> > 20090 3/007 70014 83/25=3D
>
> > 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
> > =A0 containing 2 lines similar to above. 6hr, 7hr, 8hr, 9hr& =A012 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. =A0To do
> that, the code below should get you started:
>
> dim observation as string
> Using fs As New System.IO.FileStream _
> =A0 =A0("SomeFile.Dat", System.IO.FileMode.Open)
>
> =A0 =A0Dim sr As New System.IO.StreamReader(fs)
> =A0 =A0Dim input As String =3D sr.ReadLine()
> =A0 =A0While (input <> Nothing)
>
> =A0 =A0 =A0if (not input.StartsWith("#")) then
> =A0 =A0 =A0 =A0observation =3D observation & " " & input
> =A0 =A0 =A0endif
>
> =A0 =A0 =A0if (observation.EndsWith("=3D")) then
> =A0 =A0 =A0 =A0' parse the line here...
>
> =A0 =A0 =A0 =A0' set the current observation to blank to start a new run
> =A0 =A0 =A0 =A0observation =3D ""
> =A0 =A0 =A0end if
>
> =A0 =A0 =A0input =3D sr.ReadLine()
> =A0 =A0End While
> End Using
>
> Once you have the complete line that needs parsing, you should use the
> String.Split() method. =A0This can split the string into a set of words
> representing the individual values in your input. =A0Pull the values you
> want from the array, and spit them out as desired.
>
> --
> Mike- Hide quoted text -
>
> - Show quoted text -
Thank you Mike, that's gives me a starting point.
Keith (Southend)
|
|
0
|
|
|
|
Reply
|
Keith
|
12/11/2009 8:01:36 AM
|
|
|
2 Replies
205 Views
(page loaded in 0.094 seconds)
|