Python import data form file
Go to solution
Solved by vorticalbox,
So to solve this problem I changed the file to have each line like this
QuoteBen,123456
Bill,654321
I then loaded the file with
with open(file) as f:
for line in f:
line = line.strip()
currentline = line.split(',')
info = {'name': currentline[0], 'number': currentline[1]}
dict.append(info)
then saved the file
def save():
f = open(file,'w')
for i in dict:
f.write('{},{}'.format(i['name'],i['number']))
f.close()

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now