Added methods to read data from polars.

This commit is contained in:
Alberto Soutullo Rendo 2022-11-27 18:57:31 +01:00
parent 48da9c5730
commit 3d7f0ca783
4 changed files with 25 additions and 20 deletions

View File

@ -1,16 +1,11 @@
# Python Imports
import abc
from abc import ABC
import polars as pl
class BaseDataSimulationHandler(ABC):
def __init__(self):
self._data = None
@abc.abstractmethod
def load_data(self, path):
pass
@abc.abstractmethod
def convert_into_dataframe(self):
def load_data(self, path: str) -> pl.DataFrame:
pass

View File

@ -1,10 +1,14 @@
# Python Imports
import polars as pl
# Project Imports
from src.utilities.files.simulation_data_types.base_data_simulation_handler import BaseDataSimulationHandler
class CsvDataSimulationHandler(BaseDataSimulationHandler):
def load_data(self, path):
pass
def load_data(self, path: str) -> pl.DataFrame:
polars_df = pl.read_csv(path)
return polars_df
def convert_into_dataframe(self):
pass

View File

@ -1,10 +1,13 @@
# Python Imports
import polars as pl
# Project Imports
from src.utilities.files.simulation_data_types.base_data_simulation_handler import BaseDataSimulationHandler
class JsonDataSimulationHandler(BaseDataSimulationHandler):
def load_data(self, path):
pass
def load_data(self, path: str) -> pl.DataFrame:
polars_df = pl.read_json(path)
def convert_into_dataframe(self):
pass
return polars_df

View File

@ -1,10 +1,13 @@
# Python Imports
import polars as pl
# Project Imports
from src.utilities.files.simulation_data_types.base_data_simulation_handler import BaseDataSimulationHandler
class ParquetDataSimulationHandler(BaseDataSimulationHandler):
def load_data(self, path):
pass
def load_data(self, path: str) -> pl.DataFrame:
polars_df = pl.read_parquet(path)
def convert_into_dataframe(self):
pass
return polars_df