Created
January 18, 2022 18:56
-
-
Save smhr/91ff4cb458bd66afbae8d84578f2d11f to your computer and use it in GitHub Desktop.
A simple python3 code to generate Skyroom user file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# coding: utf-8 | |
import csv | |
def user_name(s): | |
'''Read the complete name and return the username''' | |
# split the string into a list | |
l = s.split() | |
new = "" | |
# traverse in the list | |
for i in range(len(l)-1): | |
s = l[i] | |
# adds the capital first character | |
new += (s[0].lower()+'.') | |
new += l[-1].lower() | |
return new | |
data = [] | |
with open("green_users.csv", 'r') as file: | |
csvreader = csv.reader(file) | |
for row in csvreader: | |
print(row[2], user_name(row[2])) | |
row[0] = user_name(row[2]) | |
data.append(row) | |
with open('skyroom_suitable_green_users.csv', 'w', newline="") as file: | |
csvwriter = csv.writer(file) # 2. create a csvwriter object | |
# csvwriter.writerow(header) # 4. write the header | |
csvwriter.writerows(data) # 5. write the rest of the data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment