Example #1
0
    def create_data_dictionary(self, row):
        """Converts mysql data into dictionary of neo4j properties."""

        properties = OrderedDict()

        today_date = datetime.now().strftime("%Y-%m-%d")
        data = Transform.map_data(self.neo4j_mapping, row)

        for key, value in self.neo4j_properties.iteritems():
            try:
                if key == 'UpdatedDate':
                    properties.update({'UpdatedDate': today_date})

                elif key == 'PrimaryRole':
                    role = data.get('PrimaryRole')
                    label = Transform.get_neo4j_label(role)
                    if label:
                        properties.update({'PrimaryRole': label})

                else:
                    val = data.get(key)
                    properties.update({key: val})

            except Exception as e:
                self.logg(debug_msg='Error while perparing data dictionary.',
                          info_msg='Function = create_data_dictionary()',
                          warning_msg=
                          'Data transformation to key, value pair failed.',
                          error_msg='Module = ' + log_file,
                          critical_msg=str(e))
                continue

        return properties
Example #2
0
    def create_data_dictionary(self, row):
        """Converts mysql data into dictionary of neo4j properties."""

        properties = OrderedDict()

        today_date = datetime.now().strftime("%Y-%m-%d")
        data = Transform.map_data(self.neo4j_mapping, row)

        for key, value in self.neo4j_properties.iteritems():
            try:
                if key == 'UpdatedDate':
                    properties.update({'UpdatedDate': today_date})

                elif key == 'StartedOnYear':
                    StartedOn = data.get('StartedOn')
                    if StartedOn:
                        year = str(StartedOn.year)
                        properties.update({'StartedOnYear': year})

                elif key == 'StartedOnMonth':
                    StartedOn = data.get('StartedOn')
                    if StartedOn:
                        month = str(StartedOn.month)
                        properties.update({'StartedOnMonth': month})

                elif key == 'EndedOnYear':
                    EndedOn = data.get('EndedOn')
                    if EndedOn:
                        year = str(EndedOn.year)
                        properties.update({'EndedOnYear': year})

                elif key == 'EndedOnMonth':
                    EndedOn = data.get('EndedOn')
                    if EndedOn:
                        month = str(EndedOn.month)
                        properties.update({'EndedOnMonth': month})

                else:
                    val = data.get(key)
                    properties.update({key: val})

            except Exception as e:
                self.logg(debug_msg='Error while perparing data dictionary.',
                          info_msg='Function = create_data_dictionary()',
                          warning_msg=
                          'Data transformation to key, value pair failed.',
                          error_msg='Module = ' + log_file,
                          critical_msg=str(e))
                continue

        return properties
    def create_data_dictionary(self, row):
        """Converts mysql data into dictionary of neo4j properties."""

        properties = OrderedDict()

        today_date = datetime.now().strftime("%Y-%m-%d")
        data = Transform.map_data(self.neo4j_mapping, row)

        for key, value in self.neo4j_properties.iteritems():
            try:
                if key == 'UpdatedDate':
                    properties.update({'UpdatedDate': today_date})

                elif key == 'IsLeadInvestor':
                    flag = data.get(key)
                    if flag == 0:
                        properties.update({'IsLeadInvestor': 'False'})
                    elif flag == 1:
                        properties.update({'IsLeadInvestor': 'True'})

                elif key == 'Type':
                    investor_type = Transform.to_str(data.get('Type'))
                    if investor_type == 1:
                        permalink = Transform.to_str(data.get('Permalink'))
                        permalink, primary_role = self.get_organization_primary_role(
                            permalink)
                        label = Transform.get_neo4j_label(
                            Transform.to_str(primary_role))
                        properties.update({'PrimaryRole': label})

                    elif investor_type == 2:
                        properties.update({'PrimaryRole': 'Person'})

                else:
                    val = data.get(key)
                    properties.update({key: val})

            except Exception as e:
                self.logg(debug_msg='Error while perparing data dictionary.',
                          info_msg='Function = create_data_dictionary()',
                          warning_msg=
                          'Data transformation to key, value pair failed.',
                          error_msg='Module = ' + log_file,
                          critical_msg=str(e))
                continue

        return properties
Example #4
0
    def create_data_dictionary(self, row):
        """Converts mysql data into dictionary of neo4j properties."""

        properties = OrderedDict()

        today_date = datetime.now().strftime("%Y-%m-%d")
        data = Transform.map_data(self.neo4j_mapping, row)

        for key, value in self.neo4j_properties.iteritems():
            try:
                val = data.get(key)
                properties.setdefault(key, val)

            except Exception as e:
                self.logg(debug_msg='Error while perparing data dictionary.',
                          info_msg='Function = create_data_dictionary()',
                          warning_msg=
                          'Data transformation to key, value pair failed.',
                          error_msg='Module = ' + log_file,
                          critical_msg=str(e))
                continue

        return properties
    def create_data_dictionary(self, row):
        """Converts mysql data into dictionary of neo4j properties."""

        properties = OrderedDict()

        today_date = datetime.now().strftime("%Y-%m-%d")
        data = Transform.map_data(self.neo4j_mapping, row)

        for key, value in self.neo4j_properties.iteritems():
            try:
                if key == 'Source':
                    properties.setdefault('Source', 'CB')

                elif key == 'UpdatedDate':
                    properties.setdefault('UpdatedDate', today_date)

                elif key == 'IPOMonth':
                    IPODate = data.get('IPODate')
                    if IPODate:
                        month = str(IPODate.month)
                        properties.setdefault('IPOMonth', month)

                elif key == 'IPOYear':
                    IPODate = data.get('IPODate')
                    if IPODate:
                        year = str(IPODate.year)
                        properties.setdefault('IPOYear', year)

                elif key == 'HeadQuarters':
                    hq = data.get('City')
                    flag = data.get('HeadQuarterStatus')
                    if flag and hq:
                        properties.setdefault('HeadQuarters', hq)

                elif key == 'IsClosed':
                    flag = data.get('IsClosed')
                    if flag == 1:
                        properties.setdefault('IsClosed', 'Yes')
                    else:
                        properties.setdefault('IsClosed', 'No')

                elif key == 'IsDeleted':
                    flag = data.get('IsDeleted')
                    if flag == 1:
                        properties.setdefault('IsDeleted', 'Yes')
                    else:
                        properties.setdefault('IsDeleted', 'No')

                elif key == 'FoundedOnYear':
                    FoundedOn = data.get('FoundedOn')
                    if FoundedOn:
                        year = str(FoundedOn.year)
                        properties.setdefault('FoundedOnYear', year)

                elif key == 'FoundedOnMonth':
                    FoundedOn = data.get('FoundedOn')
                    if FoundedOn:
                        month = str(FoundedOn.month)
                        properties.setdefault('FoundedOnMonth', month)

                elif key == 'ClosedOnYear':
                    ClosedOn = data.get('ClosedOn')
                    if ClosedOn:
                        year = str(ClosedOn.year)
                        properties.setdefault('ClosedOnYear', year)

                elif key == 'ClosedOnMonth':
                    ClosedOn = data.get('ClosedOn')
                    if ClosedOn:
                        month = str(ClosedOn.month)
                        properties.setdefault('ClosedOnMonth', month)

                elif key == 'PrimaryRole':
                    role = Transform.to_str(data.get('PrimaryRole'))
                    label = Transform.get_neo4j_label(role)
                    if label:
                        properties.setdefault('PrimaryRole', label)
                    else:
                        properties.setdefault('PrimaryRole', '')

                elif key == 'IPOStatus':
                    ipo_id = data.get('IpoId')
                    if ipo_id:
                        deleted_ipo = data.get('DeletedIpo')
                        if not deleted_ipo:
                            properties.setdefault('IPOStatus', 'Public')

                elif key == 'CBUrl':
                    relative_path = data.get('CBUrl')
                    if relative_path:
                        relative_path = Transform.to_str(relative_path)
                        absolute_path = 'https://www.crunchbase.com/{}'.format(
                            relative_path)
                        properties.setdefault('CBUrl', absolute_path)

                else:
                    val = data.get(key)
                    properties.setdefault(key, val)

            except Exception as e:
                self.logg(debug_msg='Error while perparing data dictionary.',
                          info_msg='Function = create_data_dictionary()',
                          warning_msg=
                          'Data transformation to key, value pair failed.',
                          error_msg='Module = ' + log_file,
                          critical_msg=str(e))
                continue

        return properties
	def create_data_dictionary(self, row):
		"""Converts mysql data into dictionary of neo4j properties."""

		properties = OrderedDict()

		today_date = datetime.now().strftime("%Y-%m-%d")
		data = Transform.map_data(self.neo4j_mapping, row)

		for key, value in self.neo4j_properties.iteritems():
			try:
				if key == 'UpdatedDate':
					properties.update({'UpdatedDate':today_date})

				elif key == 'AnnoundedOnYear':
					AnnouncedOn = data.get('AnnoundedOn')
					if AnnouncedOn:
						year = str(AnnouncedOn.year)
						properties.update({'AnnoundedOnYear':year})

				elif key == 'CompletedOnYear':
					CompletedOn = data.get('CompletedOn')
					if CompletedOn:
						year = str(CompletedOn.year)
						properties.update({'CompletedOnYear':year})

				elif key == 'CompletedOnMonth':
					CompletedOn = data.get('CompletedOn')
					if CompletedOn:
						month = str(CompletedOn.month)
						properties.update({'CompletedOnMonth':month})

				elif key == 'AnnoundedOnMonth':
					AnnouncedOn = data.get('AnnoundedOn')
					if AnnouncedOn:
						month = str(AnnouncedOn.month)
						properties.update({'AnnoundedOnMonth':month})

				elif key == 'OrganizationAcquireeID':
					org_id = data.get('OrganizationAcquireeID')
					permalink, primary_role = self.get_organization_permalink(org_id)
					
					if permalink and primary_role:
						label = Transform.get_neo4j_label(primary_role)
						properties.update({'OrganizationAcquireeID':permalink})
						properties.update({'AcquireePrimaryRole':label})
					else:
						properties.update({'OrganizationAcquireeID':permalink})
						properties.update({'AcquireePrimaryRole':primary_role})
				
				elif key == 'OrganizationAcquirerID':
					org_id = data.get('OrganizationAcquirerID')
					permalink, primary_role = self.get_organization_permalink(org_id)
					if permalink and primary_role:
						label = Transform.get_neo4j_label(primary_role)
						properties.update({'OrganizationAcquirerID':permalink})
						properties.update({'AcquirerPrimaryRole':label})
					else:
						properties.update({'OrganizationAcquirerID':permalink})
						properties.update({'AcquirerPrimaryRole':primary_role})

				else:
					val = data.get(key)
					properties.update({key:val})

			except Exception as e:
				self.logg(debug_msg = 'Error while perparing data dictionary.', 
					info_msg = 'Function = create_data_dictionary()', 
					warning_msg = 'Data transformation to key, value pair failed.', 
					error_msg = 'Module = '+log_file, 
					critical_msg = str(e))
				continue

		return properties
    def create_data_dictionary(self, row):
        """Converts mysql data into dictionary of neo4j properties."""

        properties = OrderedDict()

        today_date = datetime.now().strftime("%Y-%m-%d")
        data = Transform.map_data(self.neo4j_mapping, row)

        for key, value in self.neo4j_properties.iteritems():
            try:
                if key == 'PCreatedDate':
                    properties.update({'PCreatedDate': today_date})

                elif key == 'UpdatedDate':
                    properties.update({'UpdatedDate': today_date})

                elif key == 'Gender':
                    flag = data.get('Gender')
                    if flag == 2:
                        properties.update({'Gender': 'Female'})
                    elif flag == 1:
                        properties.update({'Gender': 'Male'})
                    else:
                        properties.update({'Gender': ''})

                elif key == 'BornOnMonth':
                    BornOn = data.get('BornOn')
                    if BornOn:
                        month = str(BornOn.month)
                        properties.update({'BornOnMonth': month})

                elif key == 'BornOnYear':
                    BornOn = data.get('BornOn')
                    if BornOn:
                        year = str(BornOn.year)
                        properties.update({'BornOnYear': year})

                elif key == 'DiedOnYear':
                    DiedOn = data.get('DiedOn')
                    if DiedOn:
                        year = str(DiedOn.year)
                        properties.update({'DiedOnYear': year})

                elif key == 'DiedOnMonth':
                    DiedOn = data.get('DiedOn')
                    if DiedOn:
                        month = str(DiedOn.month)
                        properties.update({'DiedOnMonth': month})

                elif key == 'CBUrl':
                    relative_path = data.get('CBUrl')
                    if relative_path:
                        relative_path = Transform.to_str(relative_path)
                        absolute_path = 'https://www.crunchbase.com/{}'.format(
                            relative_path)
                        properties.update({'CBUrl': absolute_path})

                else:
                    val = data.get(key)
                    properties.update({key: val})

            except Exception as e:
                self.logg(debug_msg='Error while perparing data dictionary.',
                          info_msg='Function = create_data_dictionary()',
                          warning_msg=
                          'Data transformation to key, value pair failed.',
                          error_msg='Module = ' + log_file,
                          critical_msg=str(e))
                continue

        return properties