Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.advocacy > #349713
| From | Melzzzzz <mel@zzzzz.com> |
|---|---|
| Newsgroups | comp.os.linux.advocacy |
| Subject | Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds |
| Date | 2016-04-13 23:37 +0200 |
| Organization | albasani.net |
| Message-ID | <20160413233709.62cab357@maxa-pc> (permalink) |
| References | <nemcii$b8c$1@dont-email.me> |
On Wed, 13 Apr 2016 17:12:58 -0400
DFS <nospam@dfs.com> wrote:
> I was doing intermediate file read/writes. I figured out how to
> eliminate them. Code is now shorter and 38% faster.
>
> Why can't you+New/Linux+perl+sort+uniq keep up with
> me+Windows+VBScript on this simple task?
>
>
>
>
> $1 million virtual to anyone who can keep all the functionality but
> improve the speed or shorten the code further.
>
> =======================================================================
>
> 'process_addresses.vbs
> 'usage: \process_addresses.vbs inputFile outputFile
>
> Option Explicit
> Dim fso, dict, addrList, strKey, strLine
> Dim fIn, addressFile, fOut, newAddressFile
> Dim delim, business, street, citystatezip
> dim startTime, addressCount
>
> Const ForReading = 1, ForWriting = 2
> Const AdVarChar = 200, MaxCharacters = 255
>
> startTime = Timer
>
> '-----------------------------------------------------------
> 'OBJECTS
> '-----------------------------------------------------------
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set dict = CreateObject("Scripting.Dictionary")
> Set addrList = CreateObject("ADOR.Recordset")
>
>
> '-----------------------------------------------------------
> 'SETTINGS
> '-----------------------------------------------------------
> delim = ";"
> addressFile = WScript.Arguments.Item(0)
> newAddressFile = WScript.Arguments.Item(1)
>
>
> '-----------------------------------------------------------
> 'TRANSFORM DATA TO ONE ROW PER ADDRESS
> '-----------------------------------------------------------
> Set fIn = fso.OpenTextFile(addressFile , ForReading)
>
> addressCount = 0
>
> Do until fIn.AtEndOfStream
>
> business = fIn.ReadLine
> fIn.SkipLine
> strLine = Replace(fIn.ReadLine," Call Now!","")
> street = Left(strLine, InStr(strLine,",") - 1)
> citystatezip = Mid(strLine, Len(street) + 3)
> If delim = "," Then citystatezip = Replace(citystatezip,delim,"")
> strLine = business & delim & street & delim & citystatezip
>
> If Not dict.Exists(strLine) Then dict.Add strLine, strLine
> addressCount = addressCount + 1
>
> If Not fIn.AtEndOfStream Then fIn.SkipLine
> If Not fIn.AtEndOfStream Then fIn.SkipLine
>
> Loop
>
> fIn.Close
>
>
> '-----------------------------------------------------------
> 'SORT
> '-----------------------------------------------------------
> addrList.Fields.Append "Address", AdVarChar, MaxCharacters
> addrList.Open
> For Each strKey in dict.Keys
> addrList.AddNew
> addrList("Address") = strKey
> addrList.Update
> Next
> set dict = Nothing
> addrList.Sort = "Address"
>
>
>
Why spill from one to other structure? You can't place data in the
addrList in the first place? This looks pretty clumsy.
Back to comp.os.linux.advocacy | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Fabian: now I'm processing 10,000 addresses in 0.33 seconds DFS <nospam@dfs.com> - 2016-04-13 17:12 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Melzzzzz <mel@zzzzz.com> - 2016-04-13 23:37 +0200
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds DFS <nospam@dfs.com> - 2016-04-13 17:44 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Melzzzzz <mel@zzzzz.com> - 2016-04-13 23:45 +0200
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds DFS <nospam@dfs.com> - 2016-04-13 17:54 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Melzzzzz <mel@zzzzz.com> - 2016-04-14 02:41 +0200
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-13 21:00 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds DFS <nospam@dfs.com> - 2016-04-13 21:12 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Omar <omarsayeed@linuxmail.org> - 2016-04-13 21:18 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-13 19:14 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Melzzzzz <mel@zzzzz.com> - 2016-04-14 02:44 +0200
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds DFS <nospam@dfs.com> - 2016-04-13 22:31 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Melzzzzz <mel@zzzzz.com> - 2016-04-14 04:36 +0200
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-14 05:22 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds DFS <nospam@dfs.com> - 2016-04-13 22:32 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds 7 <7@enemygadgets.com> - 2016-04-14 21:54 +0000
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Omar <omarsayeed@linuxmail.org> - 2016-04-14 17:57 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-14 19:23 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds DFS <nospam@dfs.com> - 2016-04-17 13:33 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Silver Slimer <peter@klown.is> - 2016-04-17 16:57 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Melzzzzz <mel@zzzzz.com> - 2016-04-18 03:29 +0200
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Melzzzzz <mel@zzzzz.com> - 2016-04-18 04:06 +0200
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds DFS <nospam@dfs.com> - 2016-04-17 22:36 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Melzzzzz <mel@zzzzz.com> - 2016-04-18 04:45 +0200
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds owl <owl@rooftop.invalid> - 2016-04-18 02:13 +0000
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Melzzzzz <mel@zzzzz.com> - 2016-04-18 04:15 +0200
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Fabian Russell <fb@zen.info> - 2016-04-14 10:08 +0000
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Melzzzzz <mel@zzzzz.com> - 2016-04-14 13:02 +0200
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds "Dr. John Grubor" <grubor@grubor.invalid> - 2016-04-14 11:52 +0000
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds chrisv <chrisv@nospam.invalid> - 2016-04-14 06:56 -0500
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-04-14 09:03 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds DFS <nospam@dfs.com> - 2016-04-16 18:26 -0400
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds John Gohde <john.h.gohde@gmail.com> - 2016-04-14 07:23 -0700
Re: Fabian: now I'm processing 10,000 addresses in 0.33 seconds Sandman <mr@sandman.net> - 2016-04-15 18:35 +0000
csiph-web