Skip to content

Instantly share code, notes, and snippets.

@smhr
Created January 18, 2022 18:56
Show Gist options
  • Save smhr/91ff4cb458bd66afbae8d84578f2d11f to your computer and use it in GitHub Desktop.
Save smhr/91ff4cb458bd66afbae8d84578f2d11f to your computer and use it in GitHub Desktop.
A simple python3 code to generate Skyroom user file.
#!/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