In [120]:
import csv
import pandas
import matplotlib.pyplot as plt
%matplotlib inline

In [127]:
stuff = []
while True:
    add = input("what?")
    if add == 'done':
        print("end of collection")
        print(stuff)
        break
    add = float(add)
    stuff.append(add)
    
print(stuff)
df1 = pandas.DataFrame(stuff)
df1.to_csv('lets1.csv', sep=',')
new_df = pandas.read_csv('lets1.csv')
new_df


what?1
what?10
what?20
what?563
what?24
what?118
what?done
end of collection
[1.0, 10.0, 20.0, 563.0, 24.0, 118.0]
[1.0, 10.0, 20.0, 563.0, 24.0, 118.0]
Out[127]:
Unnamed: 0 0
0 0 1
1 1 10
2 2 20
3 3 563
4 4 24
5 5 118

In [128]:
new_df.plot()


Out[128]:
<matplotlib.axes._subplots.AxesSubplot at 0x1099fc908>

In [ ]:
##### stuff = []
outfile = open('test2.txt', 'a')
try:
    while True:
        add = input('add')
    #     if add == 'done':
    #         print("end of collection")
    #         print(stuff)
    #         break
        add = float(add)
        outfile.write(str(add) + ",")
except KeyboardInterrupt:
    raise
    print("done-zo")


# with open('test.txt', "wb") as file:
#     writer = csv.writer(file)
#     writer.writerow([r.get_value() for r in stuff])

# with open('test.txt', 'wb') as csvfile:
#     write = csv.writer(csvfile)
#     print(type(stuff))
# #     for i in range(len(stuff)):
#     write.writerow(stuff)

In [82]:
outfile = open('test2.txt', 'a')
for i in range(len(stuff)):
    outfile.write(str(stuff[i]) + ",")
    print(i)


0
1
2
3
4
5
6
7
8

In [114]:
new_df


Out[114]:
Unnamed: 0 0
0 0 12
1 1 23
2 2 4
3 3 5346
4 4 457

In [ ]:


In [ ]: