I'm writing a script I can use at work for bulk lotus note user registration.
Basically I need to manipulate a text file that contains a list of usernames into a file i can import into domino administrator.
For example I have a text file that contains,
Gordan.Freeman
Gordan.Freeman1
Gordan.Freeman2
And I need to get it looking like
Freeman;Gordan;;;12345678;D:\lotus\NotesIDs\Users\;GordanFreeman.id;SERVER01;mail\users\;GordanFreeman.nsf;;;;;;;;;;template.ntf;
Freeman1;Gordan;;;12345678;D:\lotus\NotesIDs\Users\;GordanFreeman1.id;SERVER01;mail\users\;GordanFreeman1.nsf;;;;;;;;;;template.ntf;
Freeman2;Gordan;;;12345678;D:\lotus\NotesIDs\Users\;GordanFreeman2.id;SERVER01;mail\users\;GordanFreeman2.nsf;;;;;;;;;;template.ntf;
I've only gotten as far as reading from the text file into a list, but from what i can tell I need to convert it back into a string before i can write to a new text file.
textloc = input(r" Enter the file path of your list (eg.'C:\names_list.txt) --> ")
textopen = open(textloc, 'r')
nameslistraw = textopen.read().split('\n')
nameslist = [i.split('.') for i in nameslistraw]
I've been fiddling around with this for hours. Any help would be great :)
Here is a working script that does what you appear to want.
file = open('myfile.txt', 'r')
temp = []
for line in file:
item = line.strip('\n').split('.')
temp.append(';'.join(item[::-1])+';'*3+'12345678;D:\lotus\NotesIDs\Users\;'+''.join(item)+'.id;SERVER01;mail\users\;'+''.join(item)+'.nsf;;;;;;;;;;template.ntf;')
file.close()
file = open('myfile.txt', 'w')
file.write('\n'.join(temp))
file.close()
Which transforms the following:
Gordan.Freeman
Gordan.Freeman1
Gordan.Freeman2
Into:
Freeman;Gordan;;;12345678;D:\lotus\NotesIDs\Users\;GordanFreeman.id;SERVER01;mail\users\;GordanFreeman.nsf;;;;;;;;;;template.ntf;
Freeman1;Gordan;;;12345678;D:\lotus\NotesIDs\Users\;GordanFreeman1.id;SERVER01;mail\users\;GordanFreeman1.nsf;;;;;;;;;;template.ntf;
Freeman2;Gordan;;;12345678;D:\lotus\NotesIDs\Users\;GordanFreeman2.id;SERVER01;mail\users\;GordanFreeman2.nsf;;;;;;;;;;template.ntf;