def __init__(self, type_, created, name, coordinates): self.id = get_random_id() self.type = type_ self.created = created self.card = barnum.create_cc_number() self.phone = barnum.create_phone() self.identification = [ get_random_id(), name, barnum.create_birthday(18, 80).toordinal() ] zipcode, city, state = barnum.create_city_state_zip() longitude, latitude = coordinates[zipcode] self.location = [zipcode, city, state, longitude, latitude]
(city, state, zipcode)) if location != None: rlocation = geolocator.reverse( "%s, %s" % (location.latitude, location.longitude)) print rlocation.address[-3:] if rlocation.address[-3:] == "USA": break print ': %s, %s, %s' % (zipcode, city, state) print ': %s' % rlocation print "." if location != None: name = barnum.create_name() now = datetime.utcnow() then = now - timedelta(2 * 365) when = random_date(then, now) birthday = barnum.create_birthday() document = { "_id": create_object_id(when), "Name": ' '.join(name), "Address": { "Street": barnum.create_street(), "City": city, "State": state, "Zip": zipcode, "Location": { "type": "Point", "coordinates": [ location.longitude + offset(), location.latitude + offset() ]
def generate_patients(count=1): random.seed() patients = [] for x in range(0, count): sex = 'Male' if random.randint(0, 1) % 2 else 'Female' fname, lname = barnum.create_name(gender=sex) mname = barnum.create_name(False, sex) if random_truth(0.27) == 1 else '' street, city, state, postal_code = generate_address() dob = barnum.create_birthday(1, 100) patient = { 'title': generate_title(sex), 'language': '', 'financial': '', 'fname': fname, 'lname': lname, 'mname': mname, 'DOB': dob.strftime("%Y-%m-%d"), 'street': street, 'postal_code': postal_code, 'city': city, 'state': state, 'country_code': 'US', 'drivers_license': random_drivers_license(lname[0], int(dob.strftime("%y"))), 'ss': random.randint(100000000, 999999999), 'occupation': barnum.create_job_title(), 'phone_home': barnum.create_phone(postal_code), 'phone_biz': barnum.create_phone(postal_code), 'phone_contact': barnum.create_phone(postal_code), 'phone_cell': barnum.create_phone(postal_code), 'pharmacy_id': 1, 'status': '', 'contact_relationship': '', 'date': barnum.create_date(past=True).strftime("%Y-%m-%d"), 'sex': sex, 'referrer': '', 'referrerID': '', 'providerID': 0, 'ref_providerID': 0, 'email': barnum.create_email(name=(fname, lname)), 'email_direct': '', 'ethnoracial': '', 'race': '', 'ethnicity': '', 'religion': '', 'interpretter': '', 'migrantseasonal': '', 'family_size': random.randint(1, 8), 'monthly_income': '', 'billing_note': '', 'homeless': '', 'financial_review': barnum.create_date(past=True).strftime("%Y-%m-%d"), 'pubpid': '', 'pid': str(random.randint(1, 99999999999)), 'hipaa_mail': 'yes' if random_truth(0.90) == 1 else 'no', 'hipaa_voice': 'yes' if random_truth(0.75) == 1 else 'no', 'hipaa_notice': 'yes' if random_truth(0.93) == 1 else 'no', 'hipaa_message': 'yes' if random_truth(0.90) == 1 else 'no', 'hipaa_allowsms': 'yes' if random_truth(0.50) == 1 else 'no', 'hipaa_allowemail': 'yes' if random_truth(0.70) == 1 else 'no', } patients.append(patient) return patients
pass all_ids.add(id_) return id_ all_ids = set() if __name__ == '__main__': with open('zip-codes.txt') as f: lines = [line.split(',') for line in f] coordinates = { row[0][1:-1]: (float(row[1][1:-1]), float(row[2][1:-1])) for row in lines if row[1] and row[2] } date_bank_created = barnum.create_birthday(5, 10).toordinal() business_accounts = [] grid = defaultdict(list) # ########################## Business accounts ########################### while len(business_accounts) < B: try: account = Account( type_='business', created=date_bank_created, name=barnum.create_company_name(), coordinates=coordinates, ) except Exception: # barnum has internal bugs continue n = random.random()
def main(): rok = 1 iloscbiur = 10 IloscAdresow = 20 IloscHoteli = 20 IloscTransportu = 20 IloscOsob = 10 lives = 10 Wycieczki = 10 transports = 10 rezyduje = 10 participate = 10 Employee = 10 typHotelu = ['*', '**', '***', '****', '*****', 'motel'] typTransportu = ['statek', 'pociag', 'autokar'] typWycieczki = ['Objazdowa', 'Wypoczynkowa', 'Planowana'] MaxDiscount = 30 trip_notes = ['transport delay', 'natural catastrophy', 'none', 'none'] typ_zaplaty = ['cash', 'card', 'bank transfer'] pozycja = ['biurowy', 'manager', 'CEO'] Teryt = [ '02', '04', '06', '08', '10', '12', '14', '16', '18', '20 ', '22', '28' ] random.seed() ##Hotel (addres , nazwa , typ E_mal , phone file = open("hotel.txt", "w") for x in range(IloscHoteli): rekord = str(random.randint( 1, IloscAdresow)) + ('|') + Ba.create_company_name() + ( '|') + random.choice(typHotelu) + ('|') + Ba.create_email() + ( '|') + Ba.create_phone() + ('|') file.write(rekord + '\n') file.close() print('Koniec ładowania hotelu') random.seed() # Transport (addres ID , nazwa , typTransportu, discount , E_mail , phone file = open("transport.txt", "w") for x in range(IloscTransportu): rekord = str(random.randint( 1, IloscAdresow)) + ('|') + Ba.create_company_name() + ( '|') + random.choice(typTransportu) + ('|') + str( random.randint( 0, MaxDiscount)) + ('|') + Ba.create_email() + ( '|') + Ba.create_phone() + ('|') file.write(rekord + '\n') file.close() ##Transports (Trip , Company) file = open("Transports.txt", "w") for x in range(transports): rekord = str(random.randint(1, Wycieczki)) + ('|') + str( random.randint(1, IloscTransportu)) + ('|') file.write(rekord + '\n') file.close() ##Osoby (name , surname , Age , e-mail , PhoneNo) random.seed() file = open("osoby.txt", "w") for x in range(IloscOsob): rekord = names.get_first_name() + ('|') + names.get_last_name() + ( '|') + str(Ba.create_birthday(3, 80)) + ( '|') + Ba.create_email() + ('|') + Ba.create_phone() + ('|') file.write(rekord + '\n') if x % 13 == 0: file1 = open("Employee.txt", "a") rozpocz = Ba.create_birthday(0, 2) if x % 3 == 0: finish = str(rozpocz + timedelta(days=(random.randint(1, 300)))) else: finish = 'none' rekord1 = str(x) + ('|') + str(rozpocz) + ('|') + str(finish) + ( '|') + str(random.choice(pozycja)) + ('|') + random.choice( Teryt) + str(random.randint(1, 10)) + ('|') file1.write(rekord1 + '\n') file1.close() file.close() ##Lives (osoba , adres) file = open("lives.txt", "w") for x in range(lives): rekord = str(random.randint(1, IloscOsob)) + ('|') + str( random.randint(1, IloscAdresow)) + ('|') file.write(rekord + '\n') file.close() ##rezyduje (Trip , Company) file = open("Residences.txt", "w") for x in range(rezyduje): rekord = str(random.randint(1, Wycieczki)) + ('|') + str( random.randint(1, IloscHoteli)) + ('|') file.write(rekord + '\n') file.close() ##Trips file = open("Trips.txt", "w") for x in range(Wycieczki): data = Ba.create_birthday(rok, rok + 1) rekord = str(data) + ('|') + str(data + timedelta(days=( random.randint(1, 14)))) + ('|') + random.choice(typWycieczki) + ( '|') + random.choice(trip_notes) + ('|') file.write(rekord + '\n') file1 = open("Participate.txt", "w") file2 = open("Bill.txt", "w") partisiopanty = random.randint(8, 30) for x in range(partisiopanty): invoice_date = data - timedelta(days=(random.randint(70, 120))) rekord1 = str(random.randint(1, IloscOsob)) + ('|') + str( random.randint(1, Wycieczki)) + ('|') + str(x) + ('|') rekord2 = str(random.randint( 1, Employee)) + ('|') + str(invoice_date) + ('|') + str( invoice_date + timedelta(days=(random.randint(2, 30)))) + ( '|') + str(random.randint(300, 3000)) + ('|') + str( random.choice(typ_zaplaty)) + ('|') file1.write(rekord1 + '\n') file2.write(rekord2 + '\n') file1.close() file2.close() file.close()
'Name': [], 'Surname': [], 'Age': [], 'Fanpages': [], 'Origin': [] }) for i in range(viewers): zip, city, state = barnum.create_city_state_zip() name, surname = barnum.create_name() df = df.append( { 'ID': '%.12g' % i, 'IDbussines': '%.12g' % rnd.randint(10000000000, 99999999999), 'Name': name, 'Surname': surname, 'Age': barnum.create_birthday(10, 80), 'Fanpages': '%.12g' % rnd.randint(0, 5), 'Origin': city }, ignore_index=True) df.to_csv("viewers.csv", index=False) '''df = pd.DataFrame({'ID': [], 'ViewerID': [], 'PostID': [], 'Like': [], 'Comment':[], 'Share': []}) for i in range(activities): df = df.append({'ID': '%.12g' % i, 'ViewerID': '%.12g' % rnd.randint(0, viewers), 'PostID': '%.12g' % rnd.randint(0, posts), 'Like': '%.12g' % rnd.randint(0, 1), 'Comment': '%.12g' % rnd.randint(0, 1), 'Share': '%.12g' % rnd.randint(0, 1)}, ignore_index=True) df.to_csv("activities.csv", index=False)''' '''import datetime