Skip to content

Logic error in condition for nested _specify_type function within the process_data factory fixture #5

@onelharrison

Description

@onelharrison

Chapter 3 Video 2

Title: Factory fixtures

Description: The current condition meant to determine whether or not to read a CSV or JSON file will lead to always trying to read CSV files.

See PR #1. The _specify_type function is a bit confusing in that it seems to be communicating that it's able to find a file based on its filename or file type, when in reality it only needs to do a search for a given filename and use the appropriate file processor to read the file based on the file's type.

Example

def _specify_file(filename):
    files = os.listdir(city_list_location)

    for f in files:
        if filename == f:
            if filename.endswith('.json'):
                data = data_processor.json_reader(city_list_location + f)
            elif filename.endswith('.csv'):
                data = data_processor.csv_reader(city_list_location + f)

             return data

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions