Beispiel #1
0
def test_teeutext():

    t1 = ((u'foo', u'bar'),
          (u'Արամ Խաչատրյան', 2),
          (u'Johann Strauß', 1),
          (u'Вагиф Сәмәдоғлу', 3))

    f1 = NamedTemporaryFile(delete=False)
    f2 = NamedTemporaryFile(delete=False)

    prologue = u'foo,bar\n'
    template = u'{foo},{bar}\n'
    epilogue = u'章子怡,4'
    (etl
     .wrap(t1)
     .teeutext(f1.name,
               template=template,
               prologue=prologue,
               epilogue=epilogue)
     .selectgt('bar', 1)
     .topickle(f2.name))

    ieq(t1 + ((u'章子怡', 4),),
        etl.fromucsv(f1.name).convertnumbers())
    ieq(etl.wrap(t1).selectgt('bar', 1),
        etl.frompickle(f2.name))
Beispiel #2
0
def test_teeucsv():

    t1 = (
        (u'name', u'id'),
        (u'Արամ Խաչատրյան', 1),
        (u'Johann Strauß', 2),
        (u'Вагиф Сәмәдоғлу', 3),
        (u'章子怡', 4),
    )

    f1 = NamedTemporaryFile(delete=False)
    f2 = NamedTemporaryFile(delete=False)

    etl.wrap(t1).teeucsv(f1.name).selectgt('id', 1).toucsv(f2.name)

    ieq(t1, etl.fromucsv(f1.name).convertnumbers())
    ieq(etl.wrap(t1).selectgt('id', 1), etl.fromucsv(f2.name).convertnumbers())
Beispiel #3
0
def test_teeucsv():

    t1 = ((u'name', u'id'),
          (u'Արամ Խաչատրյան', 1),
          (u'Johann Strauß', 2),
          (u'Вагиф Сәмәдоғлу', 3),
          (u'章子怡', 4),
          )

    f1 = NamedTemporaryFile(delete=False)
    f2 = NamedTemporaryFile(delete=False)

    etl.wrap(t1).teeucsv(f1.name).selectgt('id', 1).toucsv(f2.name)

    ieq(t1,
        etl.fromucsv(f1.name).convertnumbers())
    ieq(etl.wrap(t1).selectgt('id', 1),
        etl.fromucsv(f2.name).convertnumbers())
Beispiel #4
0
def test_teeutext():

    t1 = ((u'foo', u'bar'), (u'Արամ Խաչատրյան', 2), (u'Johann Strauß', 1),
          (u'Вагиф Сәмәдоғлу', 3))

    f1 = NamedTemporaryFile(delete=False)
    f2 = NamedTemporaryFile(delete=False)

    prologue = u'foo,bar\n'
    template = u'{foo},{bar}\n'
    epilogue = u'章子怡,4'
    (etl.wrap(t1).teeutext(f1.name,
                           template=template,
                           prologue=prologue,
                           epilogue=epilogue).selectgt('bar',
                                                       1).topickle(f2.name))

    ieq(t1 + ((u'章子怡', 4), ), etl.fromucsv(f1.name).convertnumbers())
    ieq(etl.wrap(t1).selectgt('bar', 1), etl.frompickle(f2.name))