Exemplo n.º 1
0
 def register_user(first_name, last_name, email):
     if check_user(first_name, last_name) == False:
         users = read_users()
         users.append([first_name, last_name, email])
         write_csv('users.csv', users)
         return users
     else:
         pass
Exemplo n.º 2
0
def delete_post():
    post = post_list()
    print('Delete a post!')
    postID = input('Enter Post ID: ')
    for p in post:
        if p[0] == postID:
            post.remove(p)
    write_csv('post.csv', post)
Exemplo n.º 3
0
def change_email(old_email, new_email):
    authors = read_csv('author.csv')
    for a in authors:
        for b in range(len(a)):
            if a[b] == old_email:
                a[b] = new_email

    print(authors)
    write_csv('author.csv', authors)
    return (authors)
Exemplo n.º 4
0
def change_body(title, new_body):
    articles = read_csv('article.csv')
    for a in articles:
        for b in range(len(a)):
            if b == 1 and a[b] == title:
                a[b + 1] = new_body

    write_csv('article.csv', articles)
    print(articles)
    return articles
Exemplo n.º 5
0
def delete_author(name):
    authors = read_csv('author.csv')
    for a in authors:
        for b in range(len(a)):
            if a[b] == name:
                a[b] = ""
                a[b + 1] = ""

    print(authors)
    write_csv('author.csv', authors)
    return authors
Exemplo n.º 6
0
def remove_friend_from_list():
    friend = friend_list()
    print('Remove a friend from friend list:')
    userID = input('Enter user ID: ')
    friendID = input('Enter friend ID: ')
    if (userID != '') and (friendID != ''):
        for f in friend:
            if userID == f[0] in f:
                f.remove(friendID)
        write_csv('friend.csv', friend)
    else:
        pass
Exemplo n.º 7
0
def add_friend():
    friend = friend_list()
    print('Add friend to list!')
    userID = input('Enter user ID: ')
    friendID = input('Enter friend ID: ')
    if (userID != '') and (friendID != ''):
        for f in friend:
            if userID == f[0] in f:
                f.append(friendID)
        write_csv('friend.csv', friend)
    else:
        pass
Exemplo n.º 8
0
def test_create_multiple():
    user1 = create_user('Nik', 'Jones', '*****@*****.**')
    user2 = create_user('Bobby', 'Hermsmeyer', '*****@*****.**')
    user3 = create_user('Jake', 'Loki', '*****@*****.**')
    user4 = create_user('David', 'Voss', '*****@*****.**')
    user5 = create_user('Sid', 'Campe', '*****@*****.**')
    users = [['Nik', 'Jones', '*****@*****.**'],
             ['Bobby', 'Hermsmeyer', '*****@*****.**'],
             ['Jake', 'Loki', '*****@*****.**'],
             ['David', 'Voss', '*****@*****.**'],
             ['Sid', 'Campe', '*****@*****.**'], ['', '', ''],
             ['a', 'b', '']]
    write_csv('users.csv', users)
Exemplo n.º 9
0
def new_post():
    post = post_list()
    print('Add a new post!')
    postID = input('Enter Post ID: ')
    postTitle = input('Enter Post Title: ')
    postBody = input('Enter Text: ')
    userID = input('Enter User ID: ')
    if (postID != '') and (postTitle != '') and (postBody != '') and (userID !=
                                                                      ''):
        post.append([postID, postTitle, postBody, userID])
        write_csv('post.csv', post)
        print('New Post Added Successfully!' + '\n')
    else:
        pass
Exemplo n.º 10
0
def main():
    output_file = "../data/python.csv"
    nnodes = 4000
    nrepeats = 1
    k = 10
    nedges = int(nnodes * (nnodes - 1) / 2)
    points = []
    calculate_asp_timed = time_it(calculate_asp)
    for nnodes in range(1000, 21000, 1000):
        nedges = nnodes * k
        measurements = []
        for _ in range(nrepeats):
            graph = create_graph(nnodes, nedges)
            asp, duration = calculate_asp_timed(graph)
            measurements.append(duration)
        point = (nnodes, nedges, *measurements)
        print(point)
        points.append(point)
    write_csv(output_file, points)
Exemplo n.º 11
0
def person_register():
    print("Welcome to Social Network!")
    print("Register new account!")
    loop = 'true'
    while (loop == 'true'):

        userID = input("Enter UserID:")
        userName = input("Enter UserName:"******"Enter Password:")
        person = person_list()
        friend = friend_list()

        if (userID != '') and (userName != '') and (passWord != ''):
            person.append([userID, userName, passWord])
            friend.append([userID])
            write_csv('person.csv', person)
            write_csv('friend.csv', friend)
            print('Registed Successfully!' + '\n')
            loop = 'false'
        else:
            print('Please enter required infomation!' + '\n')
Exemplo n.º 12
0
def export_to_txt():
    person = person_list()
    post = post_list()
    friend = friend_list()
    write_csv('personExport.txt',person)
    write_csv('postExport.txt',post)
    write_csv('friendExport.txt',friend)
Exemplo n.º 13
0
def import_to_csv():
    person = read_csv('personImport.txt')
    post = read_csv('postImport.txt')
    friend = read_csv('friendImport.txt')
    write_csv('person.csv',person)
    write_csv('post.csv',post)
    write_csv('friend.csv',friend)
Exemplo n.º 14
0
def add_user(name, email):
    users = user_list()
    user.append([name, email])
    write_csv('user.csv', users)
    return users
Exemplo n.º 15
0
def delete_post(postID):
    post = post_list()
    for p in post:
        if int(p[0]) == postID:
            post.remove(p)
    write_csv('post.csv', post)
Exemplo n.º 16
0
def post_textbody_change(postID, newText):
    post = post_list()
    for p in post:
        if int(p[0]) == postID:
            p[2] = newText
    write_csv('post.csv',post)
Exemplo n.º 17
0
def post_add_userID(postID, userID):
    post = post_list()
    for p in post:
        if int(p[0]) == postID:
            p[3] = userID
    write_csv('post.csv', post)            
Exemplo n.º 18
0
def post_add(postID, title, textbody, userID):
    post = post_list()
    post.append([postID, title, textbody, userID])
    write_csv('post.csv', post)
    return post
Exemplo n.º 19
0
def delete_post(postID): # later add userID to confirm same profile
    post = post_list()
    for p in post:
        if int(p[0]) == postID:
            post.remove(p)
    write_csv('post.csv', post)
Exemplo n.º 20
0
            'wide_7089.csv',
            'wide_Pal5.csv' 
           ]
center_ra = [182.525, 198.228, 199.109, 205.545, 211.36, 229.641, 250.423, 259.1680,
             322.493, 323.362, 229.013]
center_dec = [18.530, 18.164, 17.697, 28.376, 28.53, 2.083, 36.460, 43.1033,
              12.167, -0.826, -0.123]
inner_cut = [0.0170, 0.0800, 0.0500, 0.0, 0.057, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
outer_cut = [0.0700, 0.2500, 0.1400, 0.3000, 0.180, 0.2100, 0.2400, 0.1350,
             0.1900, 0.1400, 0.0870]
background_cut = [0.0800, 0.3000, 0.1700, 0.4000, 0.2500, 0.2800, 0.3300, 0.2000,
                  0.2500, 0.1800, 0.1200]
outer_back_cut = 10.0

for i in range(len(datafile)):
    if i == 7: continue
    if skip[i] == 1: continue
    data = f.read_csv(datafile[i])
    clus_data = gce.make_cut(data, center_ra[i], center_dec[i], inner_cut[i], outer_cut[i])
    back_data = gce.make_cut(data, center_ra[i], center_dec[i], background_cut[i], outer_back_cut)
    clus_out = datafile[i][:-4]+'_cluster.csv'
    back_out = datafile[i][:-4]+'_background.csv'
    if (f.write_csv(clus_data, clus_out)) == 1:
        print '#-cluster file', datafile[i], 'successfully cut and saved as', clus_out
    else:
        print '!!!AN ERROR OCCURED - FILE NOT CUT CORRECTLY!!!'
    if (f.write_csv(back_data, back_out)) == 1:
        print '#-data file', datafile[i], 'successfully cut and saved as', back_out
    else:
        print '!!!AN ERROR OCCURED - FILE NOT CUT CORRECTLY!!!'
print '#---All Done'
Exemplo n.º 21
0
def add_post():
    post = print_post_list()
    post.append([user_id, title, content])
    write_csv('user_post.csv', post)
    return post
Exemplo n.º 22
0
def add_user(userid, name, email):
    user = user_list()
    user.append([userid, name, email])
    write_csv('user.csv', user)
    return user
Exemplo n.º 23
0
def sub_add_post_from_user(postID, postTitle, postText, userID):
    post = post_list()
    post.append([postID, postTitle, postText, userID])
    write_csv('post.csv', post)
    return post
Exemplo n.º 24
0
def add_user():
    users = users_display()
    users.append([name, email])
    write_csv('users_profile.csv', users)
    return users
Exemplo n.º 25
0
 def create_post(post_content):
     posts = read_csv(first_name + '_' + last_name + '_postlogger.csv')
     for i in posts:
         num = i
     posts.append([num, post_content])
     write_csv(first_name + '_' + last_name + '_postlogger.csv', posts)
Exemplo n.º 26
0
outer_cut = [
    0.0700, 0.2500, 0.1400, 0.3000, 0.180, 0.2100, 0.2400, 0.1350, 0.1900,
    0.1400, 0.0870
]
background_cut = [
    0.0800, 0.3000, 0.1700, 0.4000, 0.2500, 0.2800, 0.3300, 0.2000, 0.2500,
    0.1800, 0.1200
]
outer_back_cut = 10.0

for i in range(len(datafile)):
    if i == 7: continue
    if skip[i] == 1: continue
    data = f.read_csv(datafile[i])
    clus_data = gce.make_cut(data, center_ra[i], center_dec[i], inner_cut[i],
                             outer_cut[i])
    back_data = gce.make_cut(data, center_ra[i], center_dec[i],
                             background_cut[i], outer_back_cut)
    clus_out = datafile[i][:-4] + '_cluster.csv'
    back_out = datafile[i][:-4] + '_background.csv'
    if (f.write_csv(clus_data, clus_out)) == 1:
        print '#-cluster file', datafile[
            i], 'successfully cut and saved as', clus_out
    else:
        print '!!!AN ERROR OCCURED - FILE NOT CUT CORRECTLY!!!'
    if (f.write_csv(back_data, back_out)) == 1:
        print '#-data file', datafile[
            i], 'successfully cut and saved as', back_out
    else:
        print '!!!AN ERROR OCCURED - FILE NOT CUT CORRECTLY!!!'
print '#---All Done'
Exemplo n.º 27
0
def post_textbody_change(postID, newText): #later add userID to confirm same profile
    post = post_list()
    for p in post:
        if int(p[0]) == postID:
            p[2] = newText
    write_csv('post.csv',post)
Exemplo n.º 28
0
def user_email_change(userID, newEmail):
    user = user_list()
    for i in user:
        if int(i[0]) == userID:
            i[2] = newEmail
    write_csv('user.csv', user)
Exemplo n.º 29
0
def add_author(name, email):
    authors = author_list()
    authors.append([name, email])
    write_csv('author.csv', authors)
    return authors
Exemplo n.º 30
0
def delete_user(userID):
    user = user_list()
    for i in user:
        if int(i[0]) == userID:
            user.remove(i)
    write_csv('user.csv', user)
Exemplo n.º 31
0
def post_add_userID(postID, userID): #when do we need this?
    post = post_list()
    for p in post:
        if int(p[0]) == postID:
            p[3] = userID
    write_csv('post.csv', post)