I'm trying to use modin and ray() but I can't move file after read it. In line shutil.move(f"./IMPORT/"+file,f"./IMPORTED/"+file)
file is still open, there is some way to close it and move it in other folder?
Here is entire code:
import os
from pathlib import Path
import shutil
import ray
import ray.util
ray.init()
import modin.pandas as pd
current_directory = os.getcwd()
import_folder_path = os.path.join(current_directory, 'IMPORT')
folder_path: Path = Path(import_folder_path)
file_list = []
file_list = list(
filter(lambda x: x if x.endswith('.xlsx') else None,
os.listdir(folder_path))
)
df2 = []
if len(file_list):
excl_list=[]
excl_merged = pd.DataFrame()
imported_file_path = os.path.join(current_directory, 'IMPORTED\\')
for file in file_list:
file_path = os.path.join(folder_path,file)
df=pd.read_excel(file_path)
df = df[df['Delivery Status'] != 'Delivered']
df2 = df.append(df)
shutil.move(f"./IMPORT/"+file,f"./IMPORTED/"+file)
output_file_path = os.path.join(folder_path,'output.xlsx')
df2.to_excel(output_file_path, index=False)
else:
print("No excel file found")
Thank you for your help