I have a file, which contains passwords/usernames:
thomas 123
john 321
What would be the best way to identify lines and add to them contact information? Right in password file I dont want store, because the size of the file matters.. I thought to add an identifier string before records, like this:
[1]
thomas 123
[2]
john 321
What do you think? It is a good way to identify lines? If yes, how I can read out line after identifier [number]?
If I can read out, then in a second file I can store contact information.
[1]
email, etc
[2]
email etc
this is a config file of an offline app, sadly I cant change the structure of that file (max. change: add an identifier before lines) or use database.
Thank you so much,
Adrian
You could use a while loop that reads every other line as your id and every other line as your username and password; however, like what @zerkms said, you’re better off putting your energy into a tried and tested database.
Learning to use a database will save you time in the future so that on each project you don’t have to figure out exactly how to manipulate a flat file.
Reusable solutions enable and empower you to focus on your goal and your product, whatever that may be.