fix directory if not exists

This commit is contained in:
karthikmurakonda 2023-10-11 06:29:44 +05:30
parent df0fe95dcc
commit 12ec9619a6
1 changed files with 2 additions and 1 deletions

View File

@ -425,7 +425,8 @@ def generateCSV(request, id, email, user_type):
applications = PlacementApplication.objects.filter(placement=opening) applications = PlacementApplication.objects.filter(placement=opening)
filename = generateRandomString() filename = generateRandomString()
if not os.path.isdir(STORAGE_DESTINATION_APPLICATION_CSV): if not os.path.isdir(STORAGE_DESTINATION_APPLICATION_CSV):
os.mkdir(STORAGE_DESTINATION_APPLICATION_CSV) # create directory if not present already even if first directory is not present
os.makedirs(STORAGE_DESTINATION_APPLICATION_CSV, exist_ok=True)
destination_path = STORAGE_DESTINATION_APPLICATION_CSV + filename + ".csv" destination_path = STORAGE_DESTINATION_APPLICATION_CSV + filename + ".csv"
f = open(destination_path, 'w') f = open(destination_path, 'w')
writer = csv.writer(f) writer = csv.writer(f)