| 1 |
"""
|
| 2 |
NativesToDataLoad
|
| 3 |
|
| 4 |
Created by
|
| 5 |
Emanuel Borges
|
| 6 |
08.25.13
|
| 7 |
|
| 8 |
This program will create a simple data load from a dir, with sub dirs, of native files. It will
|
| 9 |
even grab things like the modified data and will support docIDs.
|
| 10 |
|
| 11 |
"""
|
| 12 |
|
| 13 |
import os, time, NinoGenTools
|
| 14 |
|
| 15 |
def MakeNewDat(startDir):
|
| 16 |
outputFile = open(os.path.join(startDir,"NativeDataLoad.dat"),'w')
|
| 17 |
outputFile.write("DocID|FileName|CreateDate|FileExt|NativeFile\n")
|
| 18 |
return outputFile
|
| 19 |
|
| 20 |
def AddToDat(outputFileObj,docID,fileName,createdDate,fileExt,fileAndPath):
|
| 21 |
outputFileObj.write(docID +"|"+ fileName+"|"+createdDate+"|"+fileExt+"|"+fileAndPath+"\n")
|
| 22 |
|
| 23 |
if __name__ == '__main__':
|
| 24 |
startDir = r"W:\Manny\Client\054265-0531"
|
| 25 |
batesPrefix = "Inv_FF-"
|
| 26 |
batesPadding =9
|
| 27 |
batesStartN0 =1
|
| 28 |
counterObject = NinoGenTools.Counter()
|
| 29 |
outputFileObj = MakeNewDat(startDir)
|
| 30 |
flProps = NinoGenTools.FileProperties()
|
| 31 |
|
| 32 |
for root, dirs, files in os.walk(startDir):
|
| 33 |
for f in files:
|
| 34 |
AddToDat(outputFileObj,batesPrefix + "%0*d"% (batesPadding,counterObject.count),f,flProps.GetCreatedDate(os.path.join(root,f)),os.path.splitext(f)[1],os.path.join(root,f))
|
| 35 |
counterObject.inc(1)
|
| 36 |
|