cellyzer/io.py
def read_call(file_path="", file_type='csv', hash=True, decode_read="", splitted_line=None):
    """
    Loads call records dataset and returns a call dataset object
    :param file_path: file path of the dataset
    :param file_type: csv,xlsx,json file types are accepted
    :param hash: hash user phone numbers for privacy
    :return: CallDataset object
    """
    print("[x]  Reading Call Data")

    if type(file_path) != str or type(file_type) != str or type(hash) != bool:
        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(',')
            call_list = []
            for line in data_list[1:len(data_list) - 1]:
                splitted_line = line.split(',')
                call = dict()
                i = 0
                for f in fieldnames:
                    if splitted_line[i] is not None:
                        call[f] = splitted_line[i]
                    else:
                        call[f] = ''
                    i += 1
                call_list.append(call)
            return create_call_obj(call_list, fieldnames, hash)

        try:
            if file_type.lower() == 'csv':
                # dataset_object = read_csv(file_path)
                # return create_call_obj(dataset_object.get_records(), dataset_object.fieldnames)
                with open(file_path, 'r') as csv_file:
                    reader = csv.DictReader(csv_file)

                    fieldnames = reader.fieldnames
                    call_list = []
                    for val in reader:
                        call = dict()
                        for f in fieldnames:
                            call[f] = val[f]
                        call_list.append(call)
                    return create_call_obj(call_list, fieldnames, hash)
            elif file_type.lower() == 'xls' or file_type.lower() == 'xlsx':
                return read_xls(file_path, hash)
            elif file_type.lower() == 'json':
                return read_json(file_path, hash)
            else:
                print('Invalid Format')
        except IOError:
            print("IO Error :", IOError)
            pass

    Loads call records dataset and returns a call dataset object
    :param file_path: file path of the dataset
    :param file_type: csv,xlsx,json file types are accepted
    :param hash: hash user phone numbers for privacy
    :return: CallDataset object
    
Loads call records dataset and returns a call dataset object
Loads call records dataset and returns a call dataset object
def read_call(file_path="", file_type='csv', hash=True, decode_read="", splitted_line=None):
    print("[x]  Reading Call Data")
    if type(file_path) != str or type(file_type) != str or type(hash) != bool:
        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(',')
            call_list = []
            for line in data_list[1:len(data_list) - 1]:
                splitted_line = line.split(',')
                call = dict()
                i = 0
                for f in fieldnames:
                    if splitted_line[i] is not None:
                        call[f] = splitted_line[i]
                    else:
                        call[f] = ''
                    i += 1
                call_list.append(call)
            return create_call_obj(call_list, fieldnames, hash)
        try:
            if file_type.lower() == 'csv':
                with open(file_path, 'r') as csv_file:
                    reader = csv.DictReader(csv_file)
                    fieldnames = reader.fieldnames
                    call_list = []
                    for val in reader:
                        call = dict()
                        for f in fieldnames:
                            call[f] = val[f]
                        call_list.append(call)
                    return create_call_obj(call_list, fieldnames, hash)
            elif file_type.lower() == 'xls' or file_type.lower() == 'xlsx':
                return read_xls(file_path, hash)
            elif file_type.lower() == 'json':
                return read_json(file_path, hash)
            else:
                print('Invalid Format')
        except IOError:
            print("IO Error :", IOError)
            pass
def read_call ( file_path = "" , file_type = 'csv' , hash = True , decode_read = "" , splitted_line = None ) : print ( "[x]  Reading Call Data" ) if type ( file_path ) != str or type ( file_type ) != str or type ( hash ) != bool : 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 ( ',' ) call_list = [ ] for line in data_list [ 1 : len ( data_list ) - 1 ] : splitted_line = line . split ( ',' ) call = dict ( ) i = 0 for f in fieldnames : if splitted_line [ i ] is not None : call [ f ] = splitted_line [ i ] else : call [ f ] = '' i += 1 call_list . append ( call ) return create_call_obj ( call_list , fieldnames , hash ) try : if file_type . lower ( ) == 'csv' : with open ( file_path , 'r' ) as csv_file : reader = csv . DictReader ( csv_file ) fieldnames = reader . fieldnames call_list = [ ] for val in reader : call = dict ( ) for f in fieldnames : call [ f ] = val [ f ] call_list . append ( call ) return create_call_obj ( call_list , fieldnames , hash ) elif file_type . lower ( ) == 'xls' or file_type . lower ( ) == 'xlsx' : return read_xls ( file_path , hash ) elif file_type . lower ( ) == 'json' : return read_json ( file_path , hash ) else : print ( 'Invalid Format' ) except IOError : print ( "IO Error :" , IOError ) pass
Loads call records dataset and returns a call dataset object
Loads call records dataset and returns a call dataset object
"""
    Loads call records dataset and returns a call dataset object
    :param file_path: file path of the dataset
    :param file_type: csv,xlsx,json file types are accepted
    :param hash: hash user phone numbers for privacy
    :return: CallDataset object
    """ # dataset_object = read_csv(file_path) # return create_call_obj(dataset_object.get_records(), dataset_object.fieldnames)
None
file_path
file path of the dataset
file path of the dataset
file_type
csv,xlsx,json file types are accepted
csv xlsx json file types are accepted
hash
hash user phone numbers for privacy
hash user phone numbers for privacy
decode_read
splitted_line