From: Captain Jack on
"Keith (Southend)G" <keith_harris9(a)hotmail.com> wrote in message
news:976bfb88-51f3-47f0-80d5-4ee672d8e787(a)v25g2000yqk.googlegroups.com...
>
> 1. In the new files, now that we have them all separated I don't need
> the 1st date/time numbers.
> before:
> 14154 88963 42260 80518 11010 21023 39986 40002 57039=
> 14154 88968 41458 81410 10022 21011 39984 49999 58004 71022=
> After:
> 88963 42260 80518 11010 21023 39986 40002 57039=
> 88968 41458 81410 10022 21011 39984 49999 58004 71022=
>
> 2., More of a nicety than a necessity but is it possible to then have
> the final data in numerical order, so the 1st one would be
> '01001' (happens to be Jan Mayen(9m)-Norway) and the last probably
> '98851'(Gen.Santos(15m, Philippines)
>
> 3. Again a nicety, some locations report 'nil', so basically there's
> no data, eg.
> 14151 14447 NIL=
> In these instances nothing needs to be outputted, they can be ignored.

(1) and (3) I think will be pretty easy, but I'm not sure what you mean for
number 2. Do you want the lines in each file sorted by the numbers in the
line (but each line left intact) or do you mean you want to individual
numbers in each line to be sorted left to right, so that the output lines
look different than they do in the input file?

--
Jack


From: Keith (Southend)G on
On Jan 15, 4:09 pm, "Captain Jack" <CaptainJack1...(a)comcast.net>
wrote:
> "Keith (Southend)G" <keith_harr...(a)hotmail.com> wrote in message
>
> news:976bfb88-51f3-47f0-80d5-4ee672d8e787(a)v25g2000yqk.googlegroups.com...
>
>
>
>
>
> > 1. In the new files, now that we have them all separated I don't need
> > the 1st date/time numbers.
> > before:
> > 14154 88963 42260 80518 11010 21023 39986 40002 57039=
> > 14154 88968 41458 81410 10022 21011 39984 49999 58004 71022=
> > After:
> > 88963 42260 80518 11010 21023 39986 40002 57039=
> > 88968 41458 81410 10022 21011 39984 49999 58004 71022=
>
> > 2., More of a nicety than a necessity but is it possible to then have
> > the final data in numerical order, so the 1st one would be
> > '01001' (happens to be Jan Mayen(9m)-Norway) and the last probably
> > '98851'(Gen.Santos(15m, Philippines)
>
> > 3. Again a nicety, some locations report 'nil', so basically there's
> > no data, eg.
> > 14151 14447 NIL=
> > In these instances nothing needs to be outputted, they can be ignored.
>
> (1) and (3) I think will be pretty easy, but I'm not sure what you mean for
> number 2. Do you want the lines in each file sorted by the numbers in the
> line (but each line left intact) or do you mean you want to individual
> numbers in each line to be sorted left to right, so that the output lines
> look different than they do in the input file?
>
> --
> Jack

I've uploaded an example of what I'm looking for:
Before:
http://www.southendweather.net/1418.txt
After:
http://www.southendweather.net/1418b.txt

(I used excel, imported the 1418.txt file, deliminated it with put one
vertical line after the first date/time numbers, then sorted the
second column numerically). I use this a lot, so you can understand
why I'm pulling my hair out <grin>

Basically, the first series of 5 numbers (time/date) are removed and
then the rest are sorted numerically in order by what was the the
second series of 5 numbers, but will now be the 1st. (Clear as mud
isn't it!)

Keith (Southend)
From: Captain Jack on
"Keith (Southend)G" <keith_harris9(a)hotmail.com> wrote in message
news:c4690e7d-3a9e-416d-886d-51cdc7e61b3a(a)a32g2000yqm.googlegroups.com...
>
> I've uploaded an example of what I'm looking for:
> Before:
> http://www.southendweather.net/1418.txt
> After:
> http://www.southendweather.net/1418b.txt

Gotcha. I tried a couple of small changes to the code, but we really need
something a little more robust. Ideally, what we need to do is to read in
the data, and build a list of output file names, then, within each file
name, build (then sort) the data that will go to each file. My first thought
was to stick in a SortedList object, but it doesn't like duplicate keys.
What I'm going to do is to make some classes that will do all of the code
processing. That's better procedure anyway, that way the file processing
work is separated from the form controls, and it'll be easier to make a nice
user interface later, if you want.

I'll have some time this weekend to bang out some code, and get it set up
for you to look at. I'll be out of the office on Monday (and thus, away from
my newsreader), but I'll have you something to play with by Tuesday.
Assuming you survive whatever celebrations you're planning for the weekend,
of course. :-)

--
Jack


From: Keith (Southend)G on
On Jan 15, 9:12 pm, "Captain Jack" <CaptainJack1...(a)comcast.net>
wrote:
> "Keith (Southend)G" <keith_harr...(a)hotmail.com> wrote in message
>
> news:c4690e7d-3a9e-416d-886d-51cdc7e61b3a(a)a32g2000yqm.googlegroups.com...
>
>
>
> > I've uploaded an example of what I'm looking for:
> > Before:
> >http://www.southendweather.net/1418.txt
> > After:
> >http://www.southendweather.net/1418b.txt
>
> Gotcha. I tried a couple of small changes to the code, but we really need
> something a little more robust. Ideally, what we need to do is to read in
> the data, and build a list of output file names, then, within each file
> name, build (then sort) the data that will go to each file. My first thought
> was to stick in a SortedList object, but it doesn't like duplicate keys.
> What I'm going to do is to make some classes that will do all of the code
> processing. That's better procedure anyway, that way the file processing
> work is separated from the form controls, and it'll be easier to make a nice
> user interface later, if you want.
>
> I'll have some time this weekend to bang out some code, and get it set up
> for you to look at. I'll be out of the office on Monday (and thus, away from
> my newsreader), but I'll have you something to play with by Tuesday.
> Assuming you survive whatever celebrations you're planning for the weekend,
> of course.  :-)
>
> --
> Jack

Much appreciated Jack, don't lose any sleep over it.
Have a nice weekend, I have a big party tomorrow, will be great :-)

Keith (Southend)
From: Captain Jack on
"Keith (Southend)G" <keith_harris9(a)hotmail.com> wrote in message
news:d4890d22-a08e-4670-874c-bddf33283e54(a)14g2000yqp.googlegroups.com...
>
> Much appreciated Jack, don't lose any sleep over it.
> Have a nice weekend, I have a big party tomorrow, will be great :-)

Hope all went well for you... I had a head cold most of the weekend, but my
team won their divisional playoff game, so all was not lost. :-)

I did a rather radical re-write of the code. What I did was to create some
new classes (they appear after the form definition class) that does all of
the work of reading in the input file, reading, validating, separating, &
sorting the data, and creating the output. I removed a lot of things in the
form code that weren't relevant to the changes we had made, and put in calls
to the new object created from the new classes.

What will happen now is, if you press Button1, you'll get a copy of the raw
input file displayed in RichTextBox1. If you press Button2, the output files
will be created, and the names of all the output files will be displayed in
RichTextBox2, to show that something happened. Each button click will check
to see if the input file object has been created yet; if not it creates it.
That way, the input only gets done once, not matter which button you push
first. Since the output object appends data to the files if they already
exist, your data would be duplicated if you pushed Button2 a second time.

I added in the rule that says if the input line contains "NIL" it's not to
be processed as output. I removed the first field from the output (the one
that is used to create the file name). I have it sorting the data before
it's output, but I simplified the code by letting it do a string sort, since
the value we want to sort on appears to always have the same number of
digits. The process is a little more complex if we want to actually sort it
numerically; the way that I'd do that would be to make another class that
has that field in the full string and separately in a numeric field, then
make the class implement the IComparable interface on the numeric field. So,
this way is simpler, as long as the field is the same size every time. :-)

I tried to comment just about everything in the code, so you could see what
I was up to. To use the code, you'll need to remove all of the code that's
in the form now (or make a new project with the same controls) and put this
code in its place.

You can see the code at http://www.CaptainJack3D.com/Code/ogprog3.txt.

I should mention that there are lots of improvements that can be made to
this code. There are more efficient ways of building the data as well as
keeping it sorted. The program should probably have options for creating new
files or appending, instead of always appending. There's almost no error
checking in the code at all, so it would crash pretty spectacularly if
things aren't set up just right. I did test it with a sample file I
downloaded from the web site, and it worked on that one, anyway.

--
Jack