Commit 5d5df3f1 authored by TROUSSELLIER Laurent's avatar TROUSSELLIER Laurent
Browse files

Ajout possibilite a partir de gran = 'project'

parent 3e9ceae9
......@@ -272,30 +272,18 @@ class GuillaumeIdea(): # 1 worker / fichier
## nameCat = project+"_"+nameCat[:-1]+".csv"
## pathCat = os.path.join(dirCat,nameCat)
## ### OU BIEN EN one liner =>
pathCat = os.path.join(rootDirCat,project,"_".join([facets[drs.dir_keys[i]] for i in range(drs.dir_keys.index(str(gran))+1)])+".csv")
#print(pathCat,nameCat, "path : ",pathCat)
##########################
# On a toute les infos ...
# Append avec lock
##########################
#ft3 = time.time()
#print("3:",ft3-ft2)
# NOTE : Python 3.7> pour 'garantir' l'ordonancement du dict : https://stackoverflow.com/questions/39980323/are-dictionaries-ordered-in-python-3-6
## data = pathFromCiclad+","+project+","
## for _,v in facets.items():
## #print(k,v)
## data = data + str(v) +","
## data = data + flagLatest
pathCat=""
if (gran=="project"):
pathCat = os.path.join(rootDirCat,project,project+".csv")
else:
pathCat = os.path.join(rootDirCat,project,"_".join([facets[drs.dir_keys[i]] for i in range(drs.dir_keys.index(str(gran))+1)])+".csv")
data = os.path.join("/bdd",Path(path))+","+project +","+ ",".join(facets.values()) + ","+ flagLatest
#print(data)
#print(data)
lock = LockFile(pathCat)
#print(pathCat)
with lock:
# A TESTER : si il existe ? osef .. sinon on le cree AVEC entete ...
with open(pathCat, 'a+') as f:
#print("ON APPEND:", data)
f.write(data+"\n")
......@@ -446,7 +434,7 @@ def main():
#file = open(pathDesFichiers, 'r')
#lines = file.readlines()
#print("Done")
tempNb = 20000
tempNb = 2000
i=0
with open(pathDesFichiers) as fp:
for path in fp:
......@@ -504,7 +492,7 @@ def prependCSVAndjsonCreation(rootDirCat,project):
pattern = os.path.join(Path(rootDirCat,project),'*.csv')
#print(pattern)
for path in iglob(pattern):
#print(path)
print(path)
line_prepender(path,header)
where = rootDirCat+project
SaveJSON(path.split("/")[-1],where,header)
......@@ -565,8 +553,8 @@ if __name__ == "__main__":
print("Main de Base")
main()
print("Main Avec creation des csv ET JSON avec le premier worker ")
mainAtefIdea()
#print("Main Avec creation des csv ET JSON avec le premier worker ")
#mainAtefIdea()
# print("Test")
#protoYAML()
pass
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment