Exemplo n.º 1
0
def csv2(tmpdir, file_backends_data):
    csv2 = tmpdir.mkdir('csv_dir2')
    df = pd.merge(*file_backends_data.values(), on=['time', 'ticker'])
    f = csv2 / 'df.csv'
    df.to_csv(str(f), index=False)

    return CSVClient(tmpdir).database()
Exemplo n.º 2
0
def csv(tmpdir, file_backends_data):
    csv = tmpdir.mkdir('csv_dir')

    for k, v in file_backends_data.items():
        f = csv / '{}.csv'.format(k)
        v.to_csv(str(f), index=False)

    return CSVClient(tmpdir).database()
Exemplo n.º 3
0
def test_insert(transformed, tmpdir):
    t = transformed

    # csv's don't preserve dtypes
    expected = t.execute()
    expected['time'] = expected['time'].astype(str)

    tpath = tmpdir / 'new_csv'
    tpath.mkdir()
    path = tpath / 'foo.csv'

    assert not path.exists()
    c = ibis.csv.connect(tpath)
    c.insert('foo.csv', t)
    assert path.exists()

    # readback
    t = CSVClient(str(tpath)).database()
    result = t.list_tables()
    assert result == ['foo']

    result = t.foo.execute()
    tm.assert_frame_equal(result, expected)
Exemplo n.º 4
0
def test_client(tmpdir, file_backends_data):

    # construct with a path to a file
    csv = tmpdir

    for k, v in file_backends_data.items():
        f = csv / '{}.csv'.format(k)
        v.to_csv(str(f), index=False)

    c = CSVClient(csv / 'open.csv')
    assert c.list_databases() == []
    assert c.list_tables() == ['open']

    c = CSVClient(csv / 'close.csv')
    assert c.list_databases() == []
    assert c.list_tables() == ['close']