I have a text file as following:
[’23.5', '1.9', '11.3', '25.5', '2.7', '22.5', '3.4', '3.4', '2.9', '2.0', '2.0', '2.1', '36.0', '13.5', '7.8', '5.9', '3.2', '2.0', '13.0', '2.0', '2.4', '11.3', '28.5', '22.7', '2.6', '2.2', '7.0', '12.5', '18.2', '7.2', '13.5', '14.0', '2.4', '2.3', '2.1', '2.0', '5.3', '3.2', '3.1', '2.6', '20.0', '13.0', '1.9', '2.2', '2.3', '22.7', '30.5', '45.5', '2.8', '1.9', '30.0', '2.2', '2.0', '3.2', '2.0', '2.2', '2.2', '4.8', '2.8', '17.5', '2.1', '2.5', '3.6', '2.4', '2.0', '1.9', '2.3', '2.1', '2.0', '2.6', '3.0', '14.0', '2.0', '2.2', '12.5', '38.5', '38.0', '13.0', '3.2', '3.7', '3.7', '2.0', '2.1', '2.1', '9.3', '8.0', '27.0', '13.5', '9.3', '15.5', '17.5', '3.5', '2.0', '27.0', '2.0', '1.9', '23.2', '15.5', '6.5', '2.1', '23.0', '15.0', '3.8', '19.0', '29.0', '101.5', '26.5', '16.5', '14.0', '13.5', '10.3', '2.8', '16.0', '2.6', '24.5', '30.5', '13.0', '2.1', '2.3', '2.2', '15.0', '34.0', '2.1', '2.9', '6.8', '2.7', '12.3', '7.1', '28.5', '30.0', '8.7', '13.0', '6.0', '9.0', '15.0', '15.5', '8.0', '15.0', '1.9', '36.0', '17.0', '17.5', '28.0', '4.2', '9.0', '5.3', '7.8', '6.2', '15.5', '2.2', '14.0', '30.0', '12.5', '2.6', '10.0', '4.0', '6.7', '17.5', '2.7', '31.5', '3.8', '2.7', '21.5', '6.1', '23.0', '19.8', '2.8', '2.8', '2.2', '8.8', '1.9', '2.1', '20.5', '3.6', '10.7', '2.0', '18.7', '12.7', '2.1', '1.9', '3.0', '14.5', '2.6', '2.0', '20.7', '3.3', '29.0', '19.5', '10.0', '2.8', '4.0', '4.2', '2.4', '32.0', '2.2', '29.0', '2.4', '2.0', '20.0', '3.2', '2.2', '4.2', '2.8', '17.2', '2.0', '7.5', '15.7', '4.5', '2.8', '5.7', '2.2', '1.8', '2.4', '2.0', '2.2', '2.1', '2.0', '2.2', '2.0', '2.8', '8.0', '2.5', '3.3', '2.1', '2.0', '2.0', '2.0', '2.1', '19.5', '13.8', '9.2', '5.5', '2.5', '2.2', '2.1', '3.1', '8.6', '2.3', '3.7', '10.8', '2.1', '2.0', '2.4', '20.0', '', '', '', '', '', '', '7', '', '', '2.0', '17.4', '8.7', '3.9', '2.0', '2.0', '5.9', '3.1', '22.8', '4.1', '2.8', '7.6', '4.9', '2.7', '26.5', '2.1', '2.2', '2.4', '2.0', '3.8', '5.7', '2.8', '14.0', '2.2', '2.0', '27.5', '32.5', '3.1', '30.0', '20.5', '19.5', '25.0', '9.0', '3.7', '26.0', '13.5', '15.0', '1.9', '2.2', '3.7', '2.0', '2.2', '2.3', '2.1', '2.1', '1.9', '2.0', '2.0', '2.4', '2.3', '2.5', '16.0', '6.5', '19.5', '2.0', '4.1', '9.4', '51.5', '2.1', '15.4', '2.0', '2.1', '2.8', '2.1', '2.1', '2.6', '2.9', '20.0', '2.5', '13.0', '2.2', '1.9', '2.2', '2.3', '2.2', '2.1', '3.4', '19.5', '22.8', '2.6', '2.2', '1.9', '2.4', '2.0', '6.6', '3.2', '1.9', '2.0', '2.6', '2.0', '14.0', '2.0', '3.0', '19.8', '5.4', '3.6', '5.9', '2.2', '3.6', '2.0', '2.0', '9.8', '2.4', '3.3', '3.0', '28.0', '47.0', '5.8', '3.1', '20.5', '18.0', '32.0', '4.4', '2.1', '3.2', '2.6', '3.2', '2.5', '3.5', '1.9', '2.2', '2.3', '2.5', '2.8', '2.0', '2.4', '5.0', '6.3', '5.1', '2.5', '2.0', '2.9', '2.0', '2.4', '2.2', '3.3', '5.0', '2.6', '2.7', '1.9', '3.0', '2.1', '2.4', '2.7', '16.5', '5.2', '2.2', '2.2', '3.2', '5.5', '24.5', '17.5', '2.1', '2.7', '3.6', '2.2', '2.1', '8.1', '3.1', '2.1', '2.9', '2.1', '2.1', '2.0', '2.3', '1.9', '13.7', '3.2', '2.1', '2.6', '5.1', '23.5', '24.5', '3.1', '2.6', '3.2', '2.2', '23.0', '2.5', '8.2', '2.0', '3.7', '2.0', '2.1', '2.4', '2.7', '3.1', '2.6', '2.7', '3.2', '3.4', '4.6', '2.9', '3.3', '10.8', '2.5', '3.5', '2.0', '1.9', '2.2', '2.1', '2.1', '2.1', '2.1', '2.1', '31.8', '14.4', '1.9', '2.8', '5.0', '2.5', '2.5', '3.0', '4.3', '2.4', '2.4', '4.8', '2.0', '1.9', '2.1', '3.8', '2.5', '', '', '', '', '', '', '7', '', '', '2.0', '3.4', '2.2', '3.5', '2.1', '2.4', '2.5', '3.0', '2.1', '2.0', '5.6', '2.3', '4.9', '1.9', '1.9', '21.5', '2.4', '1.9', '2.0', '2.3', '2.8', '23.3', '6.4', '2.0', '1.9', '2.2', '2.7', '6.3', '2.5', '2.7', '2.1', '14.0', '18.7', '2.0', '2.9', '67.0', '2.2', '2.2', '2.3', '2.1', '3.1', '2.5', '2.4', '2.5', '2.1', '2.0', '28.0', '7.2', '3.1', '37.5', '17.5', '2.0', '30.0', '2.4', '2.2', '2.2', '29.0', '4.9', '2.7', '2.2', '2.2', '3.5', '4.2', '1.9', '2.0', '3.8', '1.9', '2.4', '2.8', '19.5', '16.0', '18.5', '2.9', '20.5', '3.1', '1.9', '2.3', '2.3', '30.0', '13.0', '3.2', '2.2', '2.6', '2.1', '47.0', '2.6', '2.5', '1.9', '23.3', '4.9', '3.6', '2.5', '2.1', '2.1', '17.0', '1.9', '2.7', '2.3', '2.6', '1.9', '16.5', '2.7', '3.3', '2.4', '2.2', '3.3', '2.2', '2.8', '2.1', '3.4', '3.4', '1.9', '2.0', '3.7', '2.0', '21.5', '2.1', '2.2', '2.3', '2.3', '6.8', '1.9', '2.8', '3.3', '5.4', '125.0', '2.7', '39.3', '24.0', '30.5', '2.4', '2.5', '10.0', '2.6', '2.3', '2.3', '2.4', '3.5', '2.4', '2.1', '2.0', '2.7', '18.5', '2.4', '2.0', '6.1', '4.8', '2.4', '2.1', '2.5', '2.2', '2.6', '2.0', '2.2', '2.1', '2.3', '2.1', '2.4', '2.1', '2.2', '2.9', '12.7', '12.5', '2.0', '3.0', '2.1', '2.6', '3.2', '3.0', '2.0', '2.5', '3.8', '4.9', '3.2', '1.9', '10.2', '2.0', '1.9', '9.0', '3.5', '6.6', '3.1', '2.2', '4.9', '6.7', '1.9', '5.5', '3.5', '2.2', '2.0', '2.2', '7.3', '2.1', '2.6', '5.3', '2.9', '1.9', '2.2', '2.6', '2.3', '1.9', '3.0', '2.3', '2.4', '1.9', '2.2', '2.2', '3.2', '28.8', '19.0', '2.5', '7.6', '11.4', '4.6', '2.3', '16.5', '37.5', '1.9', '2.3', '27.0', '18.5', '2.1', '31.0', '2.4', '29.5', '31.0', '2.1', '2.2', '2.4', '1.9', '2.2', '29.3', '11.1', '4.1', '29.0', '18.0', '21.0', '10.5', '2.5', '', '']
I want to remove empty string (ex: in the red column '') and use the scripts
f= open('filename.txt','r')
A1=f.read()
for i in A1:
if i=="":
A1.remove(i)
print A1
break
however the empty strings of file were still not removed
I am very confused, please help me @@
' '
sections? – Celeoopen("output.txt","w").write(str(filter(None,literal_eval(open("input.txt").read())))
– Joran Beasleyfilename.txt
as text? – Dyno Fu