File size: 688 Bytes
1822f54
 
 
 
 
 
 
 
77196ea
1822f54
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
import uuid
import shutil
import pandas as pd
import polars as pl
import time

def getDataFrame(path):
    data = pd.read_csv(path, on_bad_lines='skip', header=0, sep="\t")
    return pl.from_pandas(data)

def save_to_csv(dataframe):
    folder_path = "data"
    if not dataframe.is_empty():
        os.makedirs(folder_path, exist_ok=True)
        csv_path = f"{folder_path}/{uuid.uuid4()}.csv"
        dataframe.write_csv(csv_path, separator="\t")
        return csv_path

def delete_folder_periodically(path, interval=3600):
    while True:
        if os.path.exists(path):
            shutil.rmtree(path)
        os.makedirs(path, exist_ok=True)
        time.sleep(interval)