Exemplo n.º 1
0
def hello_world(request):
    """Responds to any HTTP request.
    Args:
        request (flask.Request): HTTP request object.
    Returns:
        The response text or any set of values that can be turned into a
        Response object using
        `make_response <http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>`.
    """
    request_json = request.get_json()

    table = request_json

    # Converting the list of list into a pandas dataframe.
    query_table = []
    for row in range(1, len(table)):
        if row != 0:
            query_table.append(table[row])
    query_table_dataframe = pandas.DataFrame(query_table, columns=table[0])

    result = date_detection.detect(query_table_dataframe)

    # converting enums to strings for returning to the UI
    for col in result.keys():
        result[col]['type'] = _column_types_enum_to_str(result[col]['type'])

    result_json = json.dumps(result)

    return result_json
Exemplo n.º 2
0
def test_7():
    """
    Detect the date columns in austin_weather.csv
    Here 2 date columns are present with different formats.
    """
    table = pandas.read_csv('data_for_tests/table_7.csv')
    result = date_detection.detect(table)
    print(result)
    expected_result = '''{'date': {'type': <ColumnTypes.CONSINTENT: 1>, 'day_first': True}, ' date__new': {'type': <ColumnTypes.CONSINTENT: 1>, 'day_first': False}}'''
    assert (expected_result == str(result))
Exemplo n.º 3
0
def test_6():
    """
    Detect the date columns in austin_weather.csv
    Example date present - '2013-12-21'
    """
    table = pandas.read_csv('data_for_tests/austin_weather.csv')
    result = date_detection.detect(table)
    print(result)
    expected_result = '''{'Date': {'type': <ColumnTypes.CONSINTENT: 1>, 'day_first': False}}'''
    assert (expected_result == str(result))
Exemplo n.º 4
0
def test_5():
    """
    Detect the date columns in orders.csv
    Example date present - '10/13/2010'
    """
    table = pandas.read_csv('data_for_tests/orders.csv')
    result = date_detection.detect(table)
    print(result)
    expected_result = '''{'Order Date': {'type': <ColumnTypes.CONSINTENT: 1>, 'day_first': False}}'''
    assert (expected_result == str(result))
Exemplo n.º 5
0
def test_4():
    """
    Detect the date columns in naukri_com.csv
    Example date present - '2019-07-06 09:20:22 +0000'
    """
    table = pandas.read_csv('data_for_tests/naukri_com.csv')
    result = date_detection.detect(table)
    print(result)
    expected_result = '''{'Crawl Timestamp': {'type': <ColumnTypes.CONSINTENT: 1>, 'day_first': False}}'''
    assert (expected_result == str(result))
Exemplo n.º 6
0
def test_2():
    """
    Detect the date columns in table_2.csv
    Date column name is 'da____t__e'
    """
    table = pandas.read_csv('data_for_tests/table_2.csv')
    result = date_detection.detect(table)
    print(result)
    expected_result = '''{'da____t__e': {'type': <ColumnTypes.CONSINTENT: 1>, 'day_first': True}}'''
    assert (expected_result == str(result))
Exemplo n.º 7
0
def test_1():
    """
    Detect the date columns in table_1.csv
    dates are in such format - '02-02-2001'
    """
    table = pandas.read_csv('data_for_tests/table_1.csv')
    result = date_detection.detect(table)
    print(result)
    expected_result = '''{'DATE': {'type': <ColumnTypes.INCONSISTENT: 3>, 'day_first': None}}'''
    assert (expected_result == str(result))
Exemplo n.º 8
0
def test_7():
    """
    Detect the date columns in austin_weather.csv
    Here 2 date columns are present with different formats.
    """
    table = pandas.read_csv('data_for_tests/table_7.csv')
    result = date_detection.detect(table)
    print(result)
    expected_result = '''{'date': {'type': <ColumnTypes.CONSISTENT: 1>, 'day_first': True, 'min_date': {'day_first_true': '1999-12-30'}, 'max_date': {'day_first_true': '2020-12-23'}}, ' date__new': {'type': <ColumnTypes.CONSISTENT: 1>, 'day_first': False, 'min_date': {'day_first_false': '2001-02-02'}, 'max_date': {'day_first_false': '2024-07-03'}}}'''
    assert(expected_result == str(result))
Exemplo n.º 9
0
def test_3():
    """
    Detect the date columns in table_3.csv
    Inconsistent date column is present. Two dates exists -
    '23-12-2020', '14-27-2016'
    """
    table = pandas.read_csv('data_for_tests/table_3.csv')
    result = date_detection.detect(table)
    print(result)
    expected_result = '''{}'''
    assert (expected_result == str(result))