I've a text.txt looking like that :
login1 fname1 lname1 mail1\n
login2 fname2 lname2 mail2\n
login3 fname3 lname3 mail3\n
login4 fname4 lname4 mail4\n
...
My goal is to create a list of each line to a list of all line, like that :
lst = [[login1, fname1, lname1, mail1],[login2, fname2, lname2, mail2],...]
I've make a script who make a list of each line, but I can't make a list inside the line... (I hope you understand...)
I've seen this link building-a-list-from-a-text-file-in-python but it's for number and I've fail to reproduc for string.
Here is my beginnig script :
file = "export_user.txt"
if os.path.exists(file):
file = open("export_user.txt", "r") #.readlines()
list_name = []
i = 0
for line in file:
list_name.append(line)
list_name[i] = list_name[i].strip()
i += 1
print(list_name)
# with open(file) as f:
# lst = [map(str(), str()) for line in f]
# print (lst[0])
1to i?list_name.append(line), you probably want to first split line up into it's components (e.g. withline_parts = line.split()), and then appendline_partstolist_name.\nlogin1, fname1, lname1, mail1a whole string or list elements?