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
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)
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)
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
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
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
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
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)
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
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)
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')
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)
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)
def add_user(name, email): users = user_list() user.append([name, email]) write_csv('user.csv', users) return users
def delete_post(postID): post = post_list() for p in post: if int(p[0]) == postID: post.remove(p) write_csv('post.csv', post)
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)
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)
def post_add(postID, title, textbody, userID): post = post_list() post.append([postID, title, textbody, userID]) write_csv('post.csv', post) return post
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)
'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'
def add_post(): post = print_post_list() post.append([user_id, title, content]) write_csv('user_post.csv', post) return post
def add_user(userid, name, email): user = user_list() user.append([userid, name, email]) write_csv('user.csv', user) return user
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
def add_user(): users = users_display() users.append([name, email]) write_csv('users_profile.csv', users) return users
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)
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'
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)
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)
def add_author(name, email): authors = author_list() authors.append([name, email]) write_csv('author.csv', authors) return authors
def delete_user(userID): user = user_list() for i in user: if int(i[0]) == userID: user.remove(i) write_csv('user.csv', user)
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)