Example #1
0
def test_see():

    table = (('foo', 'bar'), ('a', 1), ('b', 2))
    actual = repr(see(table))
    expect = """'foo': 'a', 'b'
'bar': 1, 2
"""
    eq_(expect, actual)
Example #2
0
def test_see():
    
    table = (('foo', 'bar'), ('a', 1), ('b', 2))
    actual = repr(see(table))
    expect = """'foo': 'a', 'b'
'bar': 1, 2
"""
    eq_(expect, actual)
Example #3
0
def test_see():

    table = (("foo", "bar"), ("a", 1), ("b", 2))
    actual = repr(see(table))
    expect = """'foo': 'a', 'b'
'bar': 1, 2
"""
    eq_(expect, actual)
Example #4
0
def test_see_duplicateheader():

    table = (('foo', 'bar', 'foo'), ('a', 1, 'a_prime'), ('b', 2, 'b_prime'))
    actual = repr(see(table))
    expect = """'foo': 'a', 'b'
'bar': 1, 2
'foo': 'a_prime', 'b_prime'
"""
    eq_(expect, actual)
Example #5
0
def test_see():
    """Test the see function."""

    table = (('foo', 'bar'), ('a', 1), ('b', 2))
    actual = repr(see(table))
    expect = """'foo': 'a', 'b'
'bar': 1, 2
"""
    assertequal(expect, actual)
Example #6
0
def test_see():
    """Test the see function."""
    
    table = (('foo', 'bar'), ('a', 1), ('b', 2))
    actual = repr(see(table))
    expect = """'foo': 'a', 'b'
'bar': 1, 2
"""
    assertequal(expect, actual)
Example #7
0
def test_see_duplicateheader():

    table = (("foo", "bar", "foo"), ("a", 1, "a_prime"), ("b", 2, "b_prime"))
    actual = repr(see(table))
    expect = """'foo': 'a', 'b'
'bar': 1, 2
'foo': 'a_prime', 'b_prime'
"""
    eq_(expect, actual)
Example #8
0
def create_config(csvfile,config_name):
    '''
        Creates a configuration file from a CSV file
    '''
    print csvfile
    var = ''
    try: 
        open(config_name+".ini")
        var = raw_input("This file already exists. Do you wish to continue? (Yes/No) ")
    except:
        pass
        

    if var == 'Yes':
        cfgfile = open(config_name+".ini", "w")
        examplefile = open(config_name+".example", "w")
    else:
        print "goodbye"
        sys.exit()
        

    c = fromcsv(csvfile)
    columns = header(c)
    it = iterdata(c)
    print it.next()
    examplefile.write(str(see(rowslice(c,2,3))))
    examplefile.close()


    # add the settings to the structure of the file, and lets write it out...
    Config = ConfigParser.ConfigParser()
    # dont' change  names to lower case
    Config.optionxform = str
    Config.add_section('FieldTypes')
    Config.add_section('FieldMap')
    for name in columns:
        #Config.set('FieldTypes',c)
        #print name
        new = name
        new = new.split("(", 1)[0].strip()
        # Connect words with underscore
        new = new.replace("/","_")
        new = new.replace(" ","_")
        new = new.replace("-","_")
        new = new.lower()
        # try to guess some of the names
        if "amount" in name: 
            print name
            Config.set('FieldMap',name, new + " FLOAT")
        else:
            print name
            Config.set('FieldMap',name, new + " VARCHAR(10)")
        
    Config.write(cfgfile)
    cfgfile.close()
Example #9
0
from __future__ import division, print_function, absolute_import


# look()
########

import petl as etl

table1 = [["foo", "bar"], ["a", 1], ["b", 2]]
etl.look(table1)
# alternative formatting styles
etl.look(table1, style="simple")
etl.look(table1, style="minimal")
# any irregularities in the length of header and/or data
# rows will appear as blank cells
table2 = [["foo", "bar"], ["a"], ["b", 2, True]]
etl.look(table2)


# see()
#######

import petl as etl

table = [["foo", "bar"], ["a", 1], ["b", 2]]
etl.see(table)
Example #10
0
File: vis.py Project: zli69/petl
from __future__ import division, print_function, absolute_import


# look()
########

import petl as etl
table1 = [['foo', 'bar'],
          ['a', 1],
          ['b', 2]]
etl.look(table1)
# alternative formatting styles
etl.look(table1, style='simple')
etl.look(table1, style='minimal')
# any irregularities in the length of header and/or data
# rows will appear as blank cells
table2 = [['foo', 'bar'],
          ['a'],
          ['b', 2, True]]
etl.look(table2)


# see()
#######

import petl as etl
table = [['foo', 'bar'], ['a', 1], ['b', 2]]
etl.see(table)