workspace
stringclasses
1 value
channel
stringclasses
1 value
sentences
stringlengths
1
3.93k
ts
stringlengths
26
26
user
stringlengths
2
11
sentence_id
stringlengths
44
53
timestamp
float64
1.5B
1.56B
__index_level_0__
int64
0
106k
pythondev
help
(x, y) where x is the index of the firstname and y the index of the lastname?
2017-12-15T12:55:39.000520
Tawanna
pythondev_help_Tawanna_2017-12-15T12:55:39.000520
1,513,342,539.00052
104,103
pythondev
help
So, I am creating a flask app where the models will be constantly updated in the background (once I get that running). If I wanted to have the endpoint being accessed to have the latest changes in the models and render the data in real-time for the user, what would need to be done?
2017-12-15T12:56:09.000622
Kristopher
pythondev_help_Kristopher_2017-12-15T12:56:09.000622
1,513,342,569.000622
104,104
pythondev
help
right now they're having me create a bunch of functions first and then piece it all together afterwards.
2017-12-15T12:56:18.000241
Devorah
pythondev_help_Devorah_2017-12-15T12:56:18.000241
1,513,342,578.000241
104,105
pythondev
help
I see. I don't know how your data structures are laid out
2017-12-15T12:56:49.000405
Tawanna
pythondev_help_Tawanna_2017-12-15T12:56:49.000405
1,513,342,609.000405
104,106
pythondev
help
it's horrible
2017-12-15T12:56:56.000007
Devorah
pythondev_help_Devorah_2017-12-15T12:56:56.000007
1,513,342,616.000007
104,107
pythondev
help
however, this seems like a dict or something
2017-12-15T12:57:07.000038
Tawanna
pythondev_help_Tawanna_2017-12-15T12:57:07.000038
1,513,342,627.000038
104,108
pythondev
help
the online ide won't let me check it step by step until it's all done
2017-12-15T12:57:23.000053
Devorah
pythondev_help_Devorah_2017-12-15T12:57:23.000053
1,513,342,643.000053
104,109
pythondev
help
damn. Can't you copy everything to a file and run it on your pc?
2017-12-15T12:57:47.000494
Tawanna
pythondev_help_Tawanna_2017-12-15T12:57:47.000494
1,513,342,667.000494
104,110
pythondev
help
I usually do this
2017-12-15T12:57:53.000709
Tawanna
pythondev_help_Tawanna_2017-12-15T12:57:53.000709
1,513,342,673.000709
104,111
pythondev
help
for online tests and stuff
2017-12-15T12:58:00.000357
Tawanna
pythondev_help_Tawanna_2017-12-15T12:58:00.000357
1,513,342,680.000357
104,112
pythondev
help
yeah that's what I've resorted to
2017-12-15T12:58:02.000420
Devorah
pythondev_help_Devorah_2017-12-15T12:58:02.000420
1,513,342,682.00042
104,113
pythondev
help
:thumbsup:
2017-12-15T12:58:07.000577
Tawanna
pythondev_help_Tawanna_2017-12-15T12:58:07.000577
1,513,342,687.000577
104,114
pythondev
help
it's hard to figure out with these systems what's a limitation of their teaching platform and whats the limitation of the program
2017-12-15T12:58:31.000410
Devorah
pythondev_help_Devorah_2017-12-15T12:58:31.000410
1,513,342,711.00041
104,115
pythondev
help
this data structure of names
2017-12-15T12:59:04.000407
Tawanna
pythondev_help_Tawanna_2017-12-15T12:59:04.000407
1,513,342,744.000407
104,116
pythondev
help
it sounds a lot like a dict
2017-12-15T12:59:25.000225
Tawanna
pythondev_help_Tawanna_2017-12-15T12:59:25.000225
1,513,342,765.000225
104,117
pythondev
help
Yes, it's a 2d array
2017-12-15T12:59:35.000066
Devorah
pythondev_help_Devorah_2017-12-15T12:59:35.000066
1,513,342,775.000066
104,118
pythondev
help
firstname for the key of an array of lastnames
2017-12-15T12:59:44.000123
Tawanna
pythondev_help_Tawanna_2017-12-15T12:59:44.000123
1,513,342,784.000123
104,119
pythondev
help
imported from | delimited file
2017-12-15T12:59:51.000123
Devorah
pythondev_help_Devorah_2017-12-15T12:59:51.000123
1,513,342,791.000123
104,120
pythondev
help
for me my model is a MySQL server so i can just make a direct SQL query for the freshys
2017-12-15T13:00:01.000432
Ozie
pythondev_help_Ozie_2017-12-15T13:00:01.000432
1,513,342,801.000432
104,121
pythondev
help
but when I import it locally it's giving me the \n and when I .rsplit it's not stripping it
2017-12-15T13:00:07.000661
Devorah
pythondev_help_Devorah_2017-12-15T13:00:07.000661
1,513,342,807.000661
104,122
pythondev
help
or i can analyze the request and pull from cache depending
2017-12-15T13:00:15.000517
Ozie
pythondev_help_Ozie_2017-12-15T13:00:15.000517
1,513,342,815.000517
104,123
pythondev
help
hmmmm
2017-12-15T13:00:32.000208
Tawanna
pythondev_help_Tawanna_2017-12-15T13:00:32.000208
1,513,342,832.000208
104,124
pythondev
help
you can iterate easily over the lines of the files
2017-12-15T13:00:45.000242
Tawanna
pythondev_help_Tawanna_2017-12-15T13:00:45.000242
1,513,342,845.000242
104,125
pythondev
help
if you want to get real fancy it sounds like a job for an ETL to handle
2017-12-15T13:00:57.000592
Ozie
pythondev_help_Ozie_2017-12-15T13:00:57.000592
1,513,342,857.000592
104,126
pythondev
help
with open("file") as f: for line in f: print(line)
2017-12-15T13:01:05.000087
Tawanna
pythondev_help_Tawanna_2017-12-15T13:01:05.000087
1,513,342,865.000087
104,127
pythondev
help
keep you API totally decoupled, just parses a route and makes a data request
2017-12-15T13:01:28.000126
Ozie
pythondev_help_Ozie_2017-12-15T13:01:28.000126
1,513,342,888.000126
104,128
pythondev
help
if you need the line numbers to do some specific operation you can do the following
2017-12-15T13:01:37.000655
Tawanna
pythondev_help_Tawanna_2017-12-15T13:01:37.000655
1,513,342,897.000655
104,129
pythondev
help
then your ETL system handles making sure you get the right data
2017-12-15T13:01:38.000466
Ozie
pythondev_help_Ozie_2017-12-15T13:01:38.000466
1,513,342,898.000466
104,130
pythondev
help
with open("file") as f: for i, line in enumerate(f): print(i, line)
2017-12-15T13:01:58.000003
Tawanna
pythondev_help_Tawanna_2017-12-15T13:01:58.000003
1,513,342,918.000003
104,131
pythondev
help
of course i'm relatively new and just hacking things together, there could certainly be better practices (and I'd be interested in hearing them!)
2017-12-15T13:02:04.000208
Ozie
pythondev_help_Ozie_2017-12-15T13:02:04.000208
1,513,342,924.000208
104,132
pythondev
help
So this is what I have here : ``` def load2dArrayFromFile(P): # Your code goes here: names=open(P, 'r') workers = names.read() print(workers) delimiter='|' newarray=workers.splitlines(delimiter) workers= workers[2].replace('\n', '') return newarray ```
2017-12-15T13:03:46.000102
Devorah
pythondev_help_Devorah_2017-12-15T13:03:46.000102
1,513,343,026.000102
104,133
pythondev
help
OH i just reread your thing, let me give you a better answer
2017-12-15T13:05:17.000325
Ozie
pythondev_help_Ozie_2017-12-15T13:05:17.000325
1,513,343,117.000325
104,134
pythondev
help
try what I said and print the lines
2017-12-15T13:05:37.000375
Tawanna
pythondev_help_Tawanna_2017-12-15T13:05:37.000375
1,513,343,137.000375
104,135
pythondev
help
with open(P, 'r') as names: for name in names: print(name)
2017-12-15T13:06:18.000646
Tawanna
pythondev_help_Tawanna_2017-12-15T13:06:18.000646
1,513,343,178.000646
104,136
pythondev
help
ajax request to the server from the browser?
2017-12-15T13:06:26.000273
Corrinne
pythondev_help_Corrinne_2017-12-15T13:06:26.000273
1,513,343,186.000273
104,137
pythondev
help
just to debug
2017-12-15T13:06:28.000063
Tawanna
pythondev_help_Tawanna_2017-12-15T13:06:28.000063
1,513,343,188.000063
104,138
pythondev
help
the with block is useful as it guarantees that the file is closed after you use it
2017-12-15T13:06:48.000496
Tawanna
pythondev_help_Tawanna_2017-12-15T13:06:48.000496
1,513,343,208.000496
104,139
pythondev
help
websockets?
2017-12-15T13:06:56.000571
Suellen
pythondev_help_Suellen_2017-12-15T13:06:56.000571
1,513,343,216.000571
104,140
pythondev
help
your code is leaving the file open
2017-12-15T13:06:57.000022
Tawanna
pythondev_help_Tawanna_2017-12-15T13:06:57.000022
1,513,343,217.000022
104,141
pythondev
help
the most real-time you can get
2017-12-15T13:07:06.000161
Suellen
pythondev_help_Suellen_2017-12-15T13:07:06.000161
1,513,343,226.000161
104,142
pythondev
help
I would whip up a flask-restful API (way easier than it sounds if you havent) then handle requests there and pull the required data either directly from a DB or from an ETL. You're front end would be handling the "real time" updates, i'm familar with using Angular or Knockout.js to bind elements to data models. Then yo...
2017-12-15T13:07:07.000016
Ozie
pythondev_help_Ozie_2017-12-15T13:07:07.000016
1,513,343,227.000016
104,143
pythondev
help
it shouldn't be harmful in this simple example but it can generate a lot of bugs
2017-12-15T13:07:22.000471
Tawanna
pythondev_help_Tawanna_2017-12-15T13:07:22.000471
1,513,343,242.000471
104,144
pythondev
help
strings also have the split funcion
2017-12-15T13:07:52.000439
Tawanna
pythondev_help_Tawanna_2017-12-15T13:07:52.000439
1,513,343,272.000439
104,145
pythondev
help
you can do name.split("|") to get an array of strings
2017-12-15T13:08:24.000269
Tawanna
pythondev_help_Tawanna_2017-12-15T13:08:24.000269
1,513,343,304.000269
104,146
pythondev
help
that's a good thinking question tho, what the best way to do a live check for new data....
2017-12-15T13:08:44.000607
Ozie
pythondev_help_Ozie_2017-12-15T13:08:44.000607
1,513,343,324.000607
104,147
pythondev
help
I had it that earlier but it was still giving me new lines in the string
2017-12-15T13:09:24.000374
Devorah
pythondev_help_Devorah_2017-12-15T13:09:24.000374
1,513,343,364.000374
104,148
pythondev
help
the problem was with read
2017-12-15T13:09:46.000275
Tawanna
pythondev_help_Tawanna_2017-12-15T13:09:46.000275
1,513,343,386.000275
104,149
pythondev
help
read loads the file in a single string with the "\n"s
2017-12-15T13:10:00.000377
Tawanna
pythondev_help_Tawanna_2017-12-15T13:10:00.000377
1,513,343,400.000377
104,150
pythondev
help
if you iterate over the lines that shouldn't be a problem
2017-12-15T13:10:13.000282
Tawanna
pythondev_help_Tawanna_2017-12-15T13:10:13.000282
1,513,343,413.000282
104,151
pythondev
help
``` nick|julius08025978 clash|shareef|07257980 robot|jones|08041872 sponge|square|09091999 <_io.TextIOWrapper name='python-challenge.txt' mode='r' encoding='cp1252'> None ```
2017-12-15T13:13:53.000028
Devorah
pythondev_help_Devorah_2017-12-15T13:13:53.000028
1,513,343,633.000028
104,152
pythondev
help
so that's the response I get now
2017-12-15T13:13:58.000037
Devorah
pythondev_help_Devorah_2017-12-15T13:13:58.000037
1,513,343,638.000037
104,153
pythondev
help
ok
2017-12-15T13:15:10.000440
Tawanna
pythondev_help_Tawanna_2017-12-15T13:15:10.000440
1,513,343,710.00044
104,154
pythondev
help
weird file though
2017-12-15T13:15:18.000053
Tawanna
pythondev_help_Tawanna_2017-12-15T13:15:18.000053
1,513,343,718.000053
104,155
pythondev
help
what are those blank lines?
2017-12-15T13:15:27.000205
Tawanna
pythondev_help_Tawanna_2017-12-15T13:15:27.000205
1,513,343,727.000205
104,156
pythondev
help
don't know it's is kind of weird
2017-12-15T13:15:44.000208
Devorah
pythondev_help_Devorah_2017-12-15T13:15:44.000208
1,513,343,744.000208
104,157
pythondev
help
they weren't there before
2017-12-15T13:15:47.000277
Devorah
pythondev_help_Devorah_2017-12-15T13:15:47.000277
1,513,343,747.000277
104,158
pythondev
help
if its ok to ignore them, you can
2017-12-15T13:16:57.000508
Tawanna
pythondev_help_Tawanna_2017-12-15T13:16:57.000508
1,513,343,817.000508
104,159
pythondev
help
if line.index("|") >= 0: #do stuff line.split("|")
2017-12-15T13:17:33.000269
Tawanna
pythondev_help_Tawanna_2017-12-15T13:17:33.000269
1,513,343,853.000269
104,160
pythondev
help
I forgot to add that my database is sqlite, not like that’s relevant. Are there any tutorials out there on ajax requests specific to this <@Corrinne>? I’ve never actually played with it.
2017-12-15T13:18:38.000224
Kristopher
pythondev_help_Kristopher_2017-12-15T13:18:38.000224
1,513,343,918.000224
104,161
pythondev
help
<@Ozie> ETL?
2017-12-15T13:19:07.000376
Kristopher
pythondev_help_Kristopher_2017-12-15T13:19:07.000376
1,513,343,947.000376
104,162
pythondev
help
Not that I know off the top of my head but it's quite simple
2017-12-15T13:19:15.000245
Corrinne
pythondev_help_Corrinne_2017-12-15T13:19:15.000245
1,513,343,955.000245
104,163
pythondev
help
Create a view in Flask that returns the data
2017-12-15T13:19:37.000642
Corrinne
pythondev_help_Corrinne_2017-12-15T13:19:37.000642
1,513,343,977.000642
104,164
pythondev
help
I guess a better question is to ask what I can google, I have trouble with the terminology and can be spinning my wheels.
2017-12-15T13:19:39.000596
Kristopher
pythondev_help_Kristopher_2017-12-15T13:19:39.000596
1,513,343,979.000596
104,165
pythondev
help
1 sec
2017-12-15T13:19:50.000303
Corrinne
pythondev_help_Corrinne_2017-12-15T13:19:50.000303
1,513,343,990.000303
104,166
pythondev
help
no problem
2017-12-15T13:20:02.000395
Kristopher
pythondev_help_Kristopher_2017-12-15T13:20:02.000395
1,513,344,002.000395
104,167
pythondev
help
<https://api.jquery.com/jQuery.ajax/>
2017-12-15T13:20:54.000411
Corrinne
pythondev_help_Corrinne_2017-12-15T13:20:54.000411
1,513,344,054.000411
104,168
pythondev
help
So I have it like this now ``` def load2dArrayFromFile(P): # Your code goes here: with open(P, 'r') as names: for name in names: print(name) print(names) newarray=name.split('|') print(newarray) ```
2017-12-15T13:21:11.000564
Devorah
pythondev_help_Devorah_2017-12-15T13:21:11.000564
1,513,344,071.000564
104,169
pythondev
help
and it's only giving me the last set
2017-12-15T13:21:22.000255
Devorah
pythondev_help_Devorah_2017-12-15T13:21:22.000255
1,513,344,082.000255
104,170
pythondev
help
So in your HTML template, make sure you import the jquery CDN script tag
2017-12-15T13:21:24.000072
Corrinne
pythondev_help_Corrinne_2017-12-15T13:21:24.000072
1,513,344,084.000072
104,171
pythondev
help
``` &lt;_io.TextIOWrapper name='python-challenge.txt' mode='r' encoding='cp1252'&gt; ['sponge', 'square', '09091999'] ```
2017-12-15T13:21:36.000265
Devorah
pythondev_help_Devorah_2017-12-15T13:21:36.000265
1,513,344,096.000265
104,172
pythondev
help
what I assume is i have a script that queries the database and ajax will call that script?
2017-12-15T13:21:37.000656
Kristopher
pythondev_help_Kristopher_2017-12-15T13:21:37.000656
1,513,344,097.000656
104,173
pythondev
help
A typical ajax post request looks something similar to this..
2017-12-15T13:21:42.000049
Corrinne
pythondev_help_Corrinne_2017-12-15T13:21:42.000049
1,513,344,102.000049
104,174
pythondev
help
also why is it spitting out that io.textiowrapper ?
2017-12-15T13:21:50.000298
Devorah
pythondev_help_Devorah_2017-12-15T13:21:50.000298
1,513,344,110.000298
104,175
pythondev
help
idk, but your print is outside the loop man
2017-12-15T13:22:32.000422
Tawanna
pythondev_help_Tawanna_2017-12-15T13:22:32.000422
1,513,344,152.000422
104,176
pythondev
help
it is not indented
2017-12-15T13:22:42.000219
Tawanna
pythondev_help_Tawanna_2017-12-15T13:22:42.000219
1,513,344,162.000219
104,177
pythondev
help
and you are printing names everytime, inside a loop over names
2017-12-15T13:23:08.000061
Tawanna
pythondev_help_Tawanna_2017-12-15T13:23:08.000061
1,513,344,188.000061
104,178
pythondev
help
I dont think that makes sense
2017-12-15T13:23:14.000151
Tawanna
pythondev_help_Tawanna_2017-12-15T13:23:14.000151
1,513,344,194.000151
104,179
pythondev
help
```$.ajax({ type: "POST", url: '<http://flask-app.com/data-end-point>', data: JSON.stringify(any data you want to send to the server), contentType: "application/json", dataType: "json", success: function(response){ console.log(response); }, });```
2017-12-15T13:23:24.000367
Corrinne
pythondev_help_Corrinne_2017-12-15T13:23:24.000367
1,513,344,204.000367
104,180
pythondev
help
you can print it once outside the loop
2017-12-15T13:23:27.000462
Tawanna
pythondev_help_Tawanna_2017-12-15T13:23:27.000462
1,513,344,207.000462
104,181
pythondev
help
if you want to see it
2017-12-15T13:23:34.000382
Tawanna
pythondev_help_Tawanna_2017-12-15T13:23:34.000382
1,513,344,214.000382
104,182
pythondev
help
btw, the object dump you posted is probably the output of print(names)
2017-12-15T13:24:21.000267
Tawanna
pythondev_help_Tawanna_2017-12-15T13:24:21.000267
1,513,344,261.000267
104,183
pythondev
help
in your case you might be better off using a get request
2017-12-15T13:25:00.000165
Corrinne
pythondev_help_Corrinne_2017-12-15T13:25:00.000165
1,513,344,300.000165
104,184
pythondev
help
<https://api.jquery.com/jquery.get/>
2017-12-15T13:25:09.000428
Corrinne
pythondev_help_Corrinne_2017-12-15T13:25:09.000428
1,513,344,309.000428
104,185
pythondev
help
You may also have to pip install the flask-cors package
2017-12-15T13:25:40.000334
Corrinne
pythondev_help_Corrinne_2017-12-15T13:25:40.000334
1,513,344,340.000334
104,186
pythondev
help
ok so now I have 4 lists it looks like, but it still has the \n
2017-12-15T13:31:14.000421
Devorah
pythondev_help_Devorah_2017-12-15T13:31:14.000421
1,513,344,674.000421
104,187
pythondev
help
but if I put in rsplit() in it I can strip it but then it shows up as ``` ['nick|julius08025978', ''] ['clash|shareef|07257980', ''] ['robot|jones|08041872', ''] ['sponge|square|09091999'] ```
2017-12-15T13:31:51.000018
Devorah
pythondev_help_Devorah_2017-12-15T13:31:51.000018
1,513,344,711.000018
104,188
pythondev
help
other wise it's ``` ['nick', 'julius08025978\n'] ['clash', 'shareef', '07257980\n'] ['robot', 'jones', '08041872\n'] ['sponge', 'square', '09091999'] ```
2017-12-15T13:32:06.000236
Devorah
pythondev_help_Devorah_2017-12-15T13:32:06.000236
1,513,344,726.000236
104,189
pythondev
help
sorry if I seem dense but this course has been killing me. I'm just not seeing iteration clearly yet.
2017-12-15T13:32:40.000326
Devorah
pythondev_help_Devorah_2017-12-15T13:32:40.000326
1,513,344,760.000326
104,190
pythondev
help
Your JS would likely look something like this..
2017-12-15T13:40:06.000311
Corrinne
pythondev_help_Corrinne_2017-12-15T13:40:06.000311
1,513,345,206.000311
104,191
pythondev
help
```&lt;script&gt; $.get("<http://your-server/my-data>").then(function(response){ // Do something with the response console.log(response); }); &lt;/script&gt;```
2017-12-15T13:40:13.000221
Corrinne
pythondev_help_Corrinne_2017-12-15T13:40:13.000221
1,513,345,213.000221
104,192
pythondev
help
Your flask view might look something like this..
2017-12-15T13:42:52.000060
Corrinne
pythondev_help_Corrinne_2017-12-15T13:42:52.000060
1,513,345,372.00006
104,193
pythondev
help
```@app.route("/my-data", methods=["GET", "POST"]) def dash_data(): if request.method == "GET": # Get the data you want to return from the DB return data```
2017-12-15T13:43:12.000372
Corrinne
pythondev_help_Corrinne_2017-12-15T13:43:12.000372
1,513,345,392.000372
104,194
pythondev
help
```@app.route("/my-data", methods=["GET", "POST"]) def my_data(): if request.method == "GET": # Get the data you want to return from the DB return data```
2017-12-15T13:44:31.000013
Corrinne
pythondev_help_Corrinne_2017-12-15T13:44:31.000013
1,513,345,471.000013
104,195
pythondev
help
<@Corrinne> thank you, I’ll reach out again if any questions. what would be <http://your-server/my-data> in this case? I’m assuming what I’ll need (as said earlier) is a file (.py) that queries the database. Would it be that?
2017-12-15T14:00:06.000111
Kristopher
pythondev_help_Kristopher_2017-12-15T14:00:06.000111
1,513,346,406.000111
104,196
pythondev
help
You would query the DB from the view in the flask app
2017-12-15T14:01:18.000477
Corrinne
pythondev_help_Corrinne_2017-12-15T14:01:18.000477
1,513,346,478.000477
104,197
pythondev
help
for example your `app.route("/my-data")` would be where you would query the server using the ajax script as above
2017-12-15T14:02:44.000137
Corrinne
pythondev_help_Corrinne_2017-12-15T14:02:44.000137
1,513,346,564.000137
104,198
pythondev
help
When the AJAX script runs in the browser, it makes a request to the view in Flask. The view is run and returns whatever you want it to back to the browser
2017-12-15T14:07:00.000075
Corrinne
pythondev_help_Corrinne_2017-12-15T14:07:00.000075
1,513,346,820.000075
104,199
pythondev
help
anyone familiar with git hooks?
2017-12-15T14:22:40.000558
Susann
pythondev_help_Susann_2017-12-15T14:22:40.000558
1,513,347,760.000558
104,200
pythondev
help
sorry this isn't a Python question but I'm about to pull my hair out
2017-12-15T14:22:54.000096
Susann
pythondev_help_Susann_2017-12-15T14:22:54.000096
1,513,347,774.000096
104,201
pythondev
help
<@Corrinne>: thank you for the explanation.
2017-12-15T14:25:55.000695
Kristopher
pythondev_help_Kristopher_2017-12-15T14:25:55.000695
1,513,347,955.000695
104,202