I have a huge txt file with the following values (first 5):
$42,198.98
$1,305.04
$1,821.91
$105,747.79
$100,931.55
How this list of strings could be converted into a list of numbers (meaning dropping "$" and ",")?
infile = open('sample.txt', 'r')
list_2016 = [line.rstrip() for line in infile]
infile.close()
list_2016 = [i[1:] for i in list_2016] # dropping $
list_2016 = [list_2016.replace(',', '') for i in list_2016] # dropping ','
list_2016 = [float(x) for x in list_2016]