Assigning list data as variable to create User

Solved
Cmccord1
Conversationalist

Assigning list data as variable to create User

I am pulling from a CSV file email information to create new guest network user.

The file reads like this:

 

email                        name  password

email@email.com    Bob     45646565

 

However this only works if one line of info is input to the CSV file. If i add additional line items i get an error. Can someone assist? New 🙂

 

 

with open('Guest-Test.csv', mode='r') as csv_file:
csv_reader = csv.reader(csv_file, delimiter=',')
header = next(csv_reader)

authorizations = [
{
'ssidNumber': myssidNum,
"expiresAt": expiresTS,
"authorizedByEmail": 'someemail@email.com'}]

emails_list = []
names_list = []
passwords_list = []

for row in csv_reader:
emails_list.append(row[0]),
names_list.append(row[1]),
passwords_list.append(row[2])
# print(emails)
email = ''.join(emails_list)
name = ''.join(names_list)
password = ''.join(passwords_list)

createUser = dashboard.networks.createNetworkMerakiAuthUser(
network_id, emails, names, passwords, authorizations, accountType='Guest', emailPasswordToUser=False)
1 Accepted Solution
RaphaelL
Kind of a big deal
Kind of a big deal

Hi , 

 

I think you can only create / update 1 user at a time. So instead of appending each CSV row , I would simply do that : 

 

with open('Guest-Test.csv', mode='r') as csv_file:
  csv_reader = csv.reader(csv_file, delimiter=',')
  header = next(csv_reader)

  authorizations = [
    {
      'ssidNumber': myssidNum,
      "expiresAt": expiresTS,
      "authorizedByEmail": 'someemail@email.com'}]

  email,name,password = "","",""

  for row in csv_reader:
    email = row[0]
    name = row[1]
    password = row[2]
    createUser = dashboard.networks.createNetworkMerakiAuthUser(
network_id, email, name, password, authorizations, accountType='Guest', emailPasswordToUser=False)

View solution in original post

2 Replies 2
RaphaelL
Kind of a big deal
Kind of a big deal

Hi , 

 

I think you can only create / update 1 user at a time. So instead of appending each CSV row , I would simply do that : 

 

with open('Guest-Test.csv', mode='r') as csv_file:
  csv_reader = csv.reader(csv_file, delimiter=',')
  header = next(csv_reader)

  authorizations = [
    {
      'ssidNumber': myssidNum,
      "expiresAt": expiresTS,
      "authorizedByEmail": 'someemail@email.com'}]

  email,name,password = "","",""

  for row in csv_reader:
    email = row[0]
    name = row[1]
    password = row[2]
    createUser = dashboard.networks.createNetworkMerakiAuthUser(
network_id, email, name, password, authorizations, accountType='Guest', emailPasswordToUser=False)
Cmccord1
Conversationalist

Thank you so much!  I tried this originally however my code was missing the part:  

 

email,name,password = "", "", ""

 

This makes since, and I really appreciate your response. TY

I ran the code with success.

Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.