Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Loading a text file into a table
Message
From
13/03/2002 07:11:55
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00631956
Message ID:
00631972
Views:
26
Hi Chris,

We've had the exact same requirement a few weeks ago. The way we handle this issue is by generating a unique "fingerprint" of each text file that we process. Each fingerprint is recorded in a table. Before processing a new file, we can make sure that the file has not yet been processed by looking up the fingerprint. We're using Albert Ballinger's great library FoxCrypto which you can find on the wiki (http://fox.wikis.com/wc.dll?Wiki~FoxCrypto~VFP). It is extremely fast and generates only a 16 Byte key (128bit). FWIW, here's the very simple wrapper we use and some description of what MD5 is:
*) Program...........: GtMD5.PRG
*  Author............: Daniel Gramunt
*  Project...........: Netting
*  Created...........: 05.02.2002 - 11:53:50 (Visual FoxPro 07.00.0000.9465)
*  Copyright.........: (c) Nokia, 2002
*) Description.......: Returns a 128-bit "fingerprint" of < tcString >.
*)                   : 
*)                   : MD5 was developed by Professor Ronald L. Rivest of MIT. Here's
*)                   : a description of MD5 taken from the executive summary of rfc1321: 
*)                   : [The MD5 alogirthm] takes as input a message of arbitrary length and
*)                   : produces as output a 128-bit "fingerprint" or "message digest" of the
*)                   : input. It is conjectured that it is computationally infeasible to 
*)                   : produce two messages having the same message digest, or to produce 
*)                   : any message having a given prespecified target message digest. 
*)                   : The MD5 algorithm is intended for digital signature applications, 
*)                   : where a large file must be "compressed" in a secure manner before 
*)                   : being encrypted with a private (secret) key under a public-key 
*)                   : cryptosystem such as RSA. 
*)                   : In essence, MD5 is a way to verify data integrity, and is much more
*)                   : reliabe than checksum and many other commonly used methods. 
*)                   : 
*)                   : Dependencies: This program uses Albert Ballinger's great
*)                   :               utility FoxCrypto.fll
*)                   :               http://fox.wikis.com/wc.dll?Wiki~FoxCrypto~VFP
*  Calling Samples...: lcFingerPrint = GtMd5(FILETOSTR("c:\temp\import.txt"))
*                    : IF SEEK(lcFingerPrint)
*                    :    *-- file already processed
*                    : ELSE
*                    :    *-- new file
*                    : ENDIF
*  Parameter List....: tcString - character expression for which we return 
*                    :            the MD5 fingerprint.
*  Major change list.:
*--------------------------------------------------------------------------------------------------
LPARAMETERS tcString

IF NOT "FOXCRYPTO.DLL" $ UPPER(SET("LIBRARY"))
   SET LIBRARY TO FoxCrypto.fll ADDITIVE
ENDIF

RETURN MD5(tcString)
*-- EOF GtMD5.PRG ---------------------------------------------------------------------------------
>Hi All
>
>We load heaps of comma delimited text files into tables, and I'd like to know if there is some way of checking to see if a particular file has already been loaded - as sometimes data files are loaded twice (which is a no-no). Most of the files have generic names, so we really need to check the actual contents of the file before we load it - not just the file name.
>
>If anyone has any ideas - I'm all ears!
>
>Thanks
>
>Chris Kable
Daniel
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform