Beispiel #1
0
def test_load_json():
    json = loader.load_json('boat.json')

    assert json is None

    json = loader.load_json('data/boat.json')

    assert json.shape == (100, 4)
Beispiel #2
0
    def _load(self, file_path):
        """Loads and parses a dataframe from a file.

        Args:
            file_path (str): File to be loaded.

        Returns:
            Arrays holding the features and labels.

        """

        # Getting file extension
        extension = file_path.split('.')[-1]

        if extension == 'csv':
            data = loader.load_csv(file_path)

        elif extension == 'txt':
            data = loader.load_txt(file_path)

        elif extension == 'json':
            data = loader.load_json(file_path)

        else:
            raise e.ArgumentError(
                'File extension not recognized. It should be `.csv`, `.json` or `.txt`'
            )

        X, Y = p.parse_loader(data)

        return X, Y
Beispiel #3
0
    def _load(self, file_path):
        """Loads and parses a dataframe from a file.

        Args:
            file_path (str): File to be loaded.

        Returns:
            Arrays holding the features and labels.

        """

        # Getting file extension
        extension = file_path.split('.')[-1]

        # Check if extension is .csv
        if extension == 'csv':
            # If yes, call the method that actually loads csv
            data = loader.load_csv(file_path)

        # Check if extension is .txt
        elif extension == 'txt':
            # If yes, call the method that actually loads txt
            data = loader.load_txt(file_path)

        # Check if extension is .json
        elif extension == 'json':
            # If yes, call the method that actually loads json
            data = loader.load_json(file_path)

        # If extension is not recognized
        else:
            # Raises an ArgumentError exception
            raise e.ArgumentError(
                'File extension not recognized. It should be `.csv`, `.json` or `.txt`'
            )

        # Parsing array
        X, Y = p.parse_loader(data)

        return X, Y
Beispiel #4
0
import opfython.stream.loader as l

# Loading a .csv file
csv = l.load_csv('data/sample.csv')

# Loading a .txt file
txt = l.load_txt('data/sample.txt')

# Loading a .json file
json = l.load_json('data/sample.json')
import opfython.stream.loader as l

# Loading a .csv file
csv = l.load_csv('data/boat.csv')

# Loading a .txt file
txt = l.load_txt('data/boat.txt')

# Loading a .json file
json = l.load_json('data/boat.json')