i have a file with over 15k lines each line having 1 key and 1 value. I can modify file content if any formatting is required for faster reading. currently i have made entire file like a dict and doing an eval on that is this the best way to read the file or any better approach can we follow, please suggest. File mymapfile.txt:
{
'a':'this',
'b':'that',
.
.
.
.
'xyz':'message can have "special" char %s etc '
}
and on this file i am doing eval
f_read = eval(open('mymapfile.txt', 'r').read())
my concern is my file keeps growing and values can have quotes,special char etc where we need to wrap value ''' or """. with dictionary format even if there is small syntax error eval will fail. So is it better to use readlines() without making file as dict and then create dict or eval is faster if we make dict in file? for readlines i can simply write text in each line split with : and need not worry about any special characters
File for readlines:
a:this
b:that
.
.
.
.
xyz:message can have "special" char %s etc