I am trying to read a file with lines that look like this:
1A11:A,GSEKMSTAISVLLAQAVFLLLTSQR,0.724,0,0,1,0,0,1.000,225.000,0.004,0.915
With this code:
for line in datafile:
line = line.split(',')
for element in line:
line[count] = eval(element)
And I get the following error:
"/Users/Auyer/CODING/PycharmProjects/INSERTGenerator/InsertGen.py", line 10, in fileSplitter
line[count] = eval(element)
File "<string>", line 1
1A11:A
^
SyntaxError: invalid syntax
The program works perfectly when it evaluates a number, but won't work when it does with a Punctuated String.
EDIT 1: The desired output was to have the numeric strings stored as numbers, and the strings as strings. Example: the list 'Line' would now look like this:
['1AFP:A', 'KYKKDNIKQSGKICKYVKKPRDAKFSYKGKYC', -1.494, 0, 1, 0, 0, 0, 9.000, 105.000, 0.021, 0.242]
countvariable coming from?eval()? What are you trying to do?eval(). There are much safer alternatives available, likeast.literal_eval().