Beispiel #1
0
 def __init__(self, pathin=None, list_map=default_map, delim='\t',num_cols=None):
     from delimited_file_utils import open_delimited_with_sniffer_and_check
     txt_file_with_list.__init__(self, pathin, list_map=list_map)
     self.delim = delim
     self.break_list()#<-- eventually, this could probably be eliminated
     #self.array = array(self.nested_list)
     self.array = open_delimited_with_sniffer_and_check(pathin,num_cols=num_cols)#<-- new stuff
def csv_to_xlsx(pathin, pathout=None, **kwargs):
    if pathout is None:
        fno, ext = os.path.splitext(pathin)
        pathout = fno + '.xlsx'
        
    array = delimited_file_utils.open_delimited_with_sniffer_and_check(pathin)
    array_to_xlsx(array, pathout, **kwargs)
Beispiel #3
0
 def __init__(self, pathin=None, list_map=default_map, delim='\t'):
     from delimited_file_utils import open_delimited_with_sniffer_and_check
     txt_file_with_list.__init__(self, pathin, list_map=list_map)
     self.delim = delim
     self.break_list()#<-- eventually, this could probably be eliminated
     #self.array = array(self.nested_list)
     self.array = open_delimited_with_sniffer_and_check(pathin)#<-- new stuff
Beispiel #4
0
def _open_txt_file(pathin, delim='\t'):
    #import pdb
    #pdb.set_trace()
    #myfile = txt_mixin.delimited_txt_file(pathin, delim=delim)
    #alldata = loadtxt(pathin,dtype=str,delimiter=delim)
    #alldata = myfile.array
    alldata = delimited_file_utils.open_delimited_with_sniffer_and_check(pathin)
    labels = alldata[0,:]
    data = alldata[1:]
    return data, labels
Beispiel #5
0
def _open_txt_file(pathin, delim='\t'):
    #import pdb
    #pdb.set_trace()
    #myfile = txt_mixin.delimited_txt_file(pathin, delim=delim)
    #alldata = loadtxt(pathin,dtype=str,delimiter=delim)
    #alldata = myfile.array
    alldata = delimited_file_utils.open_delimited_with_sniffer_and_check(pathin)
    labels = alldata[0,:]
    data = alldata[1:]
    return data, labels
 def __init__(self, pathin=None, lastnamecol=0, firstnamecol=1, \
              delim='\t', **kwargs):
     txt_mixin.delimited_txt_file.__init__(self, pathin, delim=delim, \
                                           **kwargs)
     myarray = open_delimited_with_sniffer_and_check(pathin)
     self.array = myarray
     self.lastnamecol = lastnamecol
     self.firstnamecol = firstnamecol
     self._get_labels_and_data()
     self._get_student_names()
     self.clean_firstnames()
     self.make_keys_and_dict()
Beispiel #7
0
    def __init__(self, pathin=None, lastnamecol=0, firstnamecol=1, \
                 delim='\t', **kwargs):
        txt_mixin.delimited_txt_file.__init__(self, pathin, delim=delim, \
                                              **kwargs)
        myarray = open_delimited_with_sniffer_and_check(pathin)
        self.array = myarray
        ## self.lastnamecol = lastnamecol
        ## self.firstnamecol = firstnamecol
        self._get_labels_and_data()
        self._set_name_cols()
        self._get_student_names()
        self.clean_firstnames()
        self.make_keys_and_dict()

        #from txt_database.__init__
        self.N_cols = len(self.labels)
        inds = range(self.N_cols)
        self.col_inds = dict(zip(self.labels, inds))
        self._col_labels_to_attr_names()
        self.map_cols_to_attr()
Beispiel #8
0
    def __init__(self, pathin=None, lastnamecol=0, firstnamecol=1, \
                 delim='\t', **kwargs):
        txt_mixin.delimited_txt_file.__init__(self, pathin, delim=delim, \
                                              **kwargs)
        myarray = open_delimited_with_sniffer_and_check(pathin)
        self.array = myarray
        ## self.lastnamecol = lastnamecol
        ## self.firstnamecol = firstnamecol
        self._get_labels_and_data()
        self._set_name_cols()
        self._get_student_names()
        self.clean_firstnames()
        self.make_keys_and_dict()

        #from txt_database.__init__
        self.N_cols = len(self.labels)
        inds = range(self.N_cols)
        self.col_inds = dict(zip(self.labels, inds))
        self._col_labels_to_attr_names()
        self.map_cols_to_attr()
import glob
from numpy import array

files = glob.glob('email_update_grades_test*.csv')

good_labels = array([
    'Group Name', 'Content/Progress', 'Clarity', 'Writing', 'Apparent Effort',
    'Overall Grade', 'Notes'
])

passes = []
failures = []

for curfile in files:
    curarray = delimited_file_utils.open_delimited_with_sniffer_and_check(
        curfile)
    labels = curarray[0, :]
    data = curarray[1:, :]
    bool_vect = labels == good_labels
    test1 = bool_vect.all()
    test2 = data.shape == (9, 7)
    if test1 and test2:
        passes.append(curfile)
    else:
        failures.append(curfile)

if len(failures) == 0:
    print('all tests pass')
else:
    print('passes:')
    for curfile in passes:
import delimited_file_utils

import glob
from numpy import array

files = glob.glob("email_update_grades_test*.csv")

good_labels = array(
    ["Group Name", "Content/Progress", "Clarity", "Writing", "Apparent Effort", "Overall Grade", "Notes"]
)

passes = []
failures = []

for curfile in files:
    curarray = delimited_file_utils.open_delimited_with_sniffer_and_check(curfile)
    labels = curarray[0, :]
    data = curarray[1:, :]
    bool_vect = labels == good_labels
    test1 = bool_vect.all()
    test2 = data.shape == (9, 7)
    if test1 and test2:
        passes.append(curfile)
    else:
        failures.append(curfile)

if len(failures) == 0:
    print("all tests pass")
else:
    print("passes:")
    for curfile in passes: