cellyzer/io.py
def read_cell(file_path='', call_csv_path=None, call_dataset_obj=None, file_type='csv', decode_read="",
              splitted_line=None):
    """
    Loads cell dataset and returns a cell dataset. In order to adda a cell-dataset,
     a call dataset object or call dataset filepath is also needed

    :param file_path: file path of the dataset
    :param call_csv_path: file path of the call dataset
    :param call_dataset_obj: call dataset object
    :param file_type: csv,xlsx,json file types are accepted
    :return: CellDataset object
    """
    print("[x]  Reading Cell Data")

    if type(file_path) != str or type(file_type) != str:
        raise TypeError
    elif type(call_csv_path) != str and call_csv_path is not None:
        raise TypeError
    elif type(call_dataset_obj).__name__ != "CallDataSet" and call_dataset_obj is not None:
        raise TypeError
    elif type(splitted_line) != list and splitted_line is not None:
        raise TypeError
    else:
        if not (decode_read == ""):
            data_list = decode_read.getvalue().split('\r\n')
            fieldnames = data_list[0].split(',')
            cell_list = []
            if call_csv_path is not None:
                call_data_set = read_call(call_csv_path)
            if call_dataset_obj is not None:
                call_data_set = call_dataset_obj
            else:
                call_data_set = None
            for line in data_list[1:len(data_list) - 1]:
                splitted_line = line.split(',')
                cell = dict()
                i = 0
                for f in fieldnames:
                    if splitted_line[i] is not None:
                        cell[f] = splitted_line[i]
                    else:
                        cell[f] = ''
                    i += 1
                cell_list.append(cell)
            return create_cell_obj(cell_list, fieldnames, call_data_set)

        try:
            if file_type.lower() == 'csv':
                with open(file_path, 'r') as csv_file:
                    reader = csv.DictReader(csv_file)
                    fieldnames = reader.fieldnames
                    cell_list = []
                    for val in reader:
                        cell = dict()
                        for f in fieldnames:
                            cell[f] = val[f]
                        cell_list.append(cell)
                    if call_csv_path is not None:
                        call_data_set = read_call(call_csv_path)
                    if call_dataset_obj is not None:
                        call_data_set = call_dataset_obj
                    else:
                        call_data_set = None
                    return create_cell_obj(cell_list, fieldnames, call_data_set)
            elif file_type.lower() == 'xls' or file_type.lower() == 'xlsx':
                if call_csv_path is not None:
                    call_data_set = read_call(call_csv_path, 'xls')
                if call_dataset_obj is not None:
                    call_data_set = call_dataset_obj
                else:
                    call_data_set = None
                return read_xls(file_path, call_data_set)
            elif file_type.lower() == 'json':
                if call_csv_path is not None:
                    call_data_set = read_call(call_csv_path, 'xls')
                if call_dataset_obj is not None:
                    call_data_set = call_dataset_obj
                else:
                    call_data_set = None
                return read_json(file_path, call_data_set)
            else:
                print('Invalid Format')
        except IOError:
            print("IO Error :", IOError)
            pass

    Loads cell dataset and returns a cell dataset. In order to adda a cell-dataset,
     a call dataset object or call dataset filepath is also needed

    :param file_path: file path of the dataset
    :param call_csv_path: file path of the call dataset
    :param call_dataset_obj: call dataset object
    :param file_type: csv,xlsx,json file types are accepted
    :return: CellDataset object
    
Loads cell dataset and returns a cell dataset. In order to adda a cell-dataset,
a call dataset object or call dataset filepath is also needed
Loads cell dataset and returns a cell dataset . In order to adda a cell - dataset a call dataset object or call dataset filepath is also needed
def read_cell(file_path='', call_csv_path=None, call_dataset_obj=None, file_type='csv', decode_read="",
              splitted_line=None):
    print("[x]  Reading Cell Data")
    if type(file_path) != str or type(file_type) != str:
        raise TypeError
    elif type(call_csv_path) != str and call_csv_path is not None:
        raise TypeError
    elif type(call_dataset_obj).__name__ != "CallDataSet" and call_dataset_obj is not None:
        raise TypeError
    elif type(splitted_line) != list and splitted_line is not None:
        raise TypeError
    else:
        if not (decode_read == ""):
            data_list = decode_read.getvalue().split('\r\n')
            fieldnames = data_list[0].split(',')
            cell_list = []
            if call_csv_path is not None:
                call_data_set = read_call(call_csv_path)
            if call_dataset_obj is not None:
                call_data_set = call_dataset_obj
            else:
                call_data_set = None
            for line in data_list[1:len(data_list) - 1]:
                splitted_line = line.split(',')
                cell = dict()
                i = 0
                for f in fieldnames:
                    if splitted_line[i] is not None:
                        cell[f] = splitted_line[i]
                    else:
                        cell[f] = ''
                    i += 1
                cell_list.append(cell)
            return create_cell_obj(cell_list, fieldnames, call_data_set)
        try:
            if file_type.lower() == 'csv':
                with open(file_path, 'r') as csv_file:
                    reader = csv.DictReader(csv_file)
                    fieldnames = reader.fieldnames
                    cell_list = []
                    for val in reader:
                        cell = dict()
                        for f in fieldnames:
                            cell[f] = val[f]
                        cell_list.append(cell)
                    if call_csv_path is not None:
                        call_data_set = read_call(call_csv_path)
                    if call_dataset_obj is not None:
                        call_data_set = call_dataset_obj
                    else:
                        call_data_set = None
                    return create_cell_obj(cell_list, fieldnames, call_data_set)
            elif file_type.lower() == 'xls' or file_type.lower() == 'xlsx':
                if call_csv_path is not None:
                    call_data_set = read_call(call_csv_path, 'xls')
                if call_dataset_obj is not None:
                    call_data_set = call_dataset_obj
                else:
                    call_data_set = None
                return read_xls(file_path, call_data_set)
            elif file_type.lower() == 'json':
                if call_csv_path is not None:
                    call_data_set = read_call(call_csv_path, 'xls')
                if call_dataset_obj is not None:
                    call_data_set = call_dataset_obj
                else:
                    call_data_set = None
                return read_json(file_path, call_data_set)
            else:
                print('Invalid Format')
        except IOError:
            print("IO Error :", IOError)
            pass
def read_cell ( file_path = '' , call_csv_path = None , call_dataset_obj = None , file_type = 'csv' , decode_read = "" , splitted_line = None ) : print ( "[x]  Reading Cell Data" ) if type ( file_path ) != str or type ( file_type ) != str : raise TypeError elif type ( call_csv_path ) != str and call_csv_path is not None : raise TypeError elif type ( call_dataset_obj ) . __name__ != "CallDataSet" and call_dataset_obj is not None : raise TypeError elif type ( splitted_line ) != list and splitted_line is not None : raise TypeError else : if not ( decode_read == "" ) : data_list = decode_read . getvalue ( ) . split ( '\r\n' ) fieldnames = data_list [ 0 ] . split ( ',' ) cell_list = [ ] if call_csv_path is not None : call_data_set = read_call ( call_csv_path ) if call_dataset_obj is not None : call_data_set = call_dataset_obj else : call_data_set = None for line in data_list [ 1 : len ( data_list ) - 1 ] : splitted_line = line . split ( ',' ) cell = dict ( ) i = 0 for f in fieldnames : if splitted_line [ i ] is not None : cell [ f ] = splitted_line [ i ] else : cell [ f ] = '' i += 1 cell_list . append ( cell ) return create_cell_obj ( cell_list , fieldnames , call_data_set ) try : if file_type . lower ( ) == 'csv' : with open ( file_path , 'r' ) as csv_file : reader = csv . DictReader ( csv_file ) fieldnames = reader . fieldnames cell_list = [ ] for val in reader : cell = dict ( ) for f in fieldnames : cell [ f ] = val [ f ] cell_list . append ( cell ) if call_csv_path is not None : call_data_set = read_call ( call_csv_path ) if call_dataset_obj is not None : call_data_set = call_dataset_obj else : call_data_set = None return create_cell_obj ( cell_list , fieldnames , call_data_set ) elif file_type . lower ( ) == 'xls' or file_type . lower ( ) == 'xlsx' : if call_csv_path is not None : call_data_set = read_call ( call_csv_path , 'xls' ) if call_dataset_obj is not None : call_data_set = call_dataset_obj else : call_data_set = None return read_xls ( file_path , call_data_set ) elif file_type . lower ( ) == 'json' : if call_csv_path is not None : call_data_set = read_call ( call_csv_path , 'xls' ) if call_dataset_obj is not None : call_data_set = call_dataset_obj else : call_data_set = None return read_json ( file_path , call_data_set ) else : print ( 'Invalid Format' ) except IOError : print ( "IO Error :" , IOError ) pass
Loads cell dataset and returns a cell dataset.
Loads cell dataset and returns a cell dataset .
"""
    Loads cell dataset and returns a cell dataset. In order to adda a cell-dataset,
     a call dataset object or call dataset filepath is also needed

    :param file_path: file path of the dataset
    :param call_csv_path: file path of the call dataset
    :param call_dataset_obj: call dataset object
    :param file_type: csv,xlsx,json file types are accepted
    :return: CellDataset object
    """
None
file_path
file path of the dataset
file path of the dataset
call_csv_path
file path of the call dataset
file path of the call dataset
call_dataset_obj
call dataset object
call dataset object
file_type
csv,xlsx,json file types are accepted
csv xlsx json file types are accepted
decode_read
splitted_line