« first day (3929 days earlier)      last day (1022 days later) » 

1:19 AM
guys
<div class="c-bg-img-center" style="height:800px; background-image: url('{% "index/img/content/shop3/21.jpg" %} ')">
how do i get this to work in django, incline css in html
 
2:12 AM
cbg
 
 
2 hours later…
3:42 AM
cbg
 
 
4 hours later…
7:20 AM
cbg
@jeffstyle mate quite a few of us are if you have a question post and if anyone can help we will
 
7:47 AM
For some reason I am always having trouble with matplotlib's compatibility with other packages
Ohh nvm I forgot I have 2 different installations of jupyter notebook in different environments. Setting the kernel to a different environment from where the notebook is installed bugs things out
 
 
1 hour later…
9:02 AM
Hi everyone.
2021-03-17T09:41:58+00:00
how can I get this format using python datetime?
Using python datetime.now(), I am getting something like this 2021-07-19 08:55:09.742517
 
Use strftime to format dates/datetimes/etc.
 
2021-03-17 => this is the date.
T => ? (how can I get this)
09:41:58 => that's the time
+00:00 => and this?
 
cbg guys, what does stackoverflow.com/questions/43252542/… mean? my aim here is to find the response time for a api call I make
 
@DeepakVerma programiz.com/python-programming/datetime/strftime here is a bit more detailed on using the strftime
 
9:19 AM
@DeepakVerma I think you are specifically looking for isoformat.
 
@python_user I just used the answer wthin the question there and got the response time from the request I ran
 
I mean, what does the comment mean when they mention "this won't get you the time it takes to download the response from the server, but only the time it takes until you get the return headers without the response contents"
 
yes @MisterMiyagi, thanks. I got it now. I needed the isoformat.
 
hey guys I have a dag within an airflow pipeline, within the ui I have manually clicked run and it is with a status of running, however the tasks within it doesn't seem to be running
 
thanks everyone
 
9:21 AM
@python_user As I understand it, it only records the duration until some data arrived, not all of it.
 
I tend to understand the same from that comment
 
Say you are downloading 1GB of data, the elapsed time is between requesting the data and receiving the first byte, not all of them.
 
so this basically is the time it takes to respond initially and not the time it takes to serve me the entire request, did I understand it correct?
 
At least that's how I'm reading the comment.
 
thanks MM and kwsswart for the (re)assurance
 
9:26 AM
Np ^^ glad MM participated as got reassurance also ^^
 
I just got confused with the return headers part, MM just made it simpler to understand
 
Think I am going to have to take my question to main as experimenting with it but not sure whats going on why it isn't executing the tasks within the pipeline, however stating is running
 
idk about airflow, so I cant help :/ and I also havent been on main for like 2 months now so I am kinda rusty
 
I havent posted a question in 5 months so yeah gno put some time into making it right
as to airflow started with it on friday... trying to build an automated data pipeline for my company help us automate scheduled tasks
 
I used to intern at a place and they would just sneak in some apache wherever they can, I always found it forced, but then again I believe python can do everything which apparently is not right, might want to understand someday
 
9:34 AM
thing is from research it actually makes sense to implement a datapipeline considering each month we will need to "repeat" certain tasks to collect, transform and upload the data
 
9:54 AM
Love that time when you are halfway through writing a question and in research for the question you solve the problem
 
10:48 AM
the magic of MCVEs
 
11:12 AM
Trying to explain an algorithm to some nontechnical people. "... Then it calculates A = max(pow(B,C),D)". Listener X asks, "what's this comma-C thing?". Listener Y replies, "that's an 'argument'. It tells max that the result can't be any larger than C"
Listener Y, I like your enthusiasm. But your parentheses counting needs a little tuning.
 
Poor nontechnical people. What are they doing looking at something like that?
 
I gave them a nontechnical explanation of the feature and they asked "but what happens in scenario Z?" enough times that we drilled down to the actual math
They were following along OK while the algorithm was just arithmetic and algebra, but functions didn't go over well. I'm currently poking around with MathJax to see if I can document this without using commas.
pow is easy enough to replace with actual exponentiation syntax, max less so
 
Has Listener X never used Excel?
 
I'm guessing they've used it, but have never written a formula in it
 
I'm not sure if that qualifies as "using" Excel
 
11:25 AM
He who uses Excel without formulas, has forgotten the face of his father
4
 
11:43 AM
cbg
@Kevin If I remember correctly function is learnt at begining of high school or so and that is only one parameter function
so toot hard for the layman
 
@Kevin you could show max like the notation used in a step function in math notation
@Kevin this got a proper chuckle out of me :P
 
Yeah I was thinking of notation along those lines, like the formula at en.wikipedia.org/wiki/Step_function
 
yeah
 
math.meta.stackexchange.com/questions/5020/… indicates that this isn't too hard to do
 
% I don't remember the syntax for \cases
A = \left\lbrace
  \begin{matrix}
    B^C if B^C \geq D \\
    D if B^C < D
  \end{matrix}
  \right.
& before each if is optional for spacing in a 2x2 matrix rather than a 2x1 column vector
but yeah, the post you linked is idiomatic
although arguably max({this, that}) might be clearer than defining this piecewise function
 
11:59 AM
\(A = \begin{cases} B^C, & \text{if } B^C > D \\ D, & \text{otherwise} gives me a serviceable result when I plug it into mathjax.org/#demo
 
Perhaps just pseudo math with $A = B^C \text{ but at least } D$ is understandable for non-techies
 
Trying to decide if it's really worth it to write out B^C more than once, as it's a bit hairier in the real scenario
 
@Kevin just reverse the logic
Ah, no, you can't. I mean it wouln't help.
 
Alas.
"B^C but at least D" is tempting
 
use an asspression
 
12:02 PM
^Andras'd
 
Plan B is to make the formula more complicated than it needs to be, so everybody assumes you need a rocket science degree to understand any of it, and leaves me alone
 
cbg
I'm implementing a genetic algorithm for a feature and I really hope I won't have to explain any of the mess I wrote
 
Nobody wants to hear an explanation of a genetic algorithm. "So now I need to know rocket science and biology? No thanks"
 
that's rocket surgery right there
 
12:18 PM
It's just like the birds and the bits...
 
12:33 PM
Hi guys,
for table in tables:
c.execute('select count(1) from '+table)
c.fetchall()
print(c)

This gets stuck sometimes. Any ideas why? Sometimes, it'll give correct results for all the tables, but other times just gets stuck in the terminal and when pressing ctrl+c it'll show some of the results
 
Maybe the stdout buffer is holding onto your output for a bit too long. Try sys.stdout.flush() inside your loop
 
12:51 PM
Is the print(c) inside the loop or outside?
 
1:13 PM
cbg
 
 
1 hour later…
2:38 PM
@Kevin or just add flush=True as an argument to print?
 
2:51 PM
cbge @JonClements
 
oh hey - how you been?
 
@JonClements improving my well being because of mentalheath problem. And also realized that stackoverflow is free work for a company which advertise a lot
 
pleased to hear your mental health is on the mend... I hope it keeps up. These are strange days for us all.
 
 
1 hour later…
3:57 PM
@Kevin "but what happens when" - awesome, let them build out your testcases and just give them a way to run them in Jupyter or something!
 
@Aran-Fey Before now, I've seen someone doing addition on a calculator and then typing the results back into the spreadsheet. That gives a confusing and complicated emotional response reserved only for that special moment
 
Ooof
 
@MisterMiyagi print(c) inside the loop
 
What database is it? As in, SQLite, MySQL, Postgres...?
 
4:13 PM
oracle
 
Ok, well that's my theory out the window :/
 
I am using cx_oracle for making connection with the database
oh, thanks though
but what actually happens is, I tried running the queries through cursor and pandas, both methods
 
Are you closing your connections?
 
In both, sometimes, it happens to get stuck
yes, closing connection
but only once, should I close connection in every iteration?
 
always ? Are you sure that .close() gets run in every code path possible? And no, there is no need to close on every iteration, but always at the end of a process. Do you have access to the dev dashboard to see active connections?
 
4:17 PM
no, don't have access to that, but can manage that. I'll try that one
.close() I am doing in every code path possible.
actually I am making two connections, first extracting the data from first connection and then closing it, then from the second connection, then closing that one
 
 
2 hours later…
6:41 PM
Hello, Can someone help with string split without the use of pandas please.... :(
import re
str = '"2000-07-09, 09:56:04",su**********************@example.co,Geothermal,0,925,ios,,"United Kingdom"'
str = re.split(r',|\"', str)
print(str)
Expected Output:
['2000-07-09, 09:56:04', 'su**********************@example.co', 'Geothermal', '0', '925', 'ios', '', 'United Kingdom']
Basically, string between " needs to be treated as one value even if it contains other delimiters. Can someone please suggest some efficient ways?
 
Try the csv module. It's pretty smart about not splitting on delimiters inside quotes.
I suspect it's theoretically possible to write a regex that skips un-enquotened commas, but it's probably a real pain to get it exactly right
 
csv module excepts only one character as delimiter...
 
Your one character is a comma. It checks out.
I don't think you can easily re.split with that condition.
You'd sooner be able to match all fields, handling string-valued fields separately
 
Oh, I'm surprised that csv can't do multiple delimiters. I thought the Dialect class would be flexible enough to handle fancier cases, but the docs disagree.
But as Andras says, it looks like you only have one delimiter, so maybe it doesn't matter. Quote marks aren't delimiters, strictly speaking.
 
7:37 PM
though re.split(r',', str) works for most of my inputs, it doesn't seem to work for below :(
str = '"2000-07-01 17:35:50",,"“I wanted to work for a company that is going to be part of the biggest change the world will see.”: A conversation with Melbourne based analyst, Firstname Lastname",0,7,web,,'
 
Why are you still not using the csv module?
 
The file is broken. Why are you trying to fix this downstream when it should never have been written with mixed delimiters in the first place?
 
i am using csv module... f1.writerow('somedata', 'somedata2', str[0], str[1], etc...
basically I cant write the row data directly along with some other data.... writerow takes only one argument... Also i need to change the delimiter so that another application(dont have much control) can read the data with new delemeter... for example: '~'. If i just leave it as ',' then its spliting the code whever its seeing the ','
well the data is messed up in upstream which is an api output from SaaS service provider... so dont have much control over it... just trying to make it better whatever i can...
 
Mixed delimiters...? I guess I must've missed something here. Pretend I didn't say anything
 
In a non-harsh way, I don't believe you. Something in your writer is causing this
 
7:48 PM
let me ping the upstream output...
 
writerow does only take one argument, and that should be a list/tuple representing a row that you've already parsed out sensibly
 
"'2000-07-01 17:31:37",,"Making a great first impression without compromising the real you”: A conversation with manager, Firstname lastname",0,33,web,,

"'2000-07-01 17:35:50",,"“I wanted to work for a company that is going to be part of the biggest change the world will see.”: A conversation with Melbourne based analyst, Firstname Lastname",0,7,web,,
sample data from upstream in csv file...
 
"basically I cant write the row data directly along with some other data". If you're saying you want your file to contain both csv and non-csv data, I think that would be a bad idea.
 
An API couldn't send you that (I'm relatively confident on that) so it's garbled somewhere else
 
aws glue needs one delemiter which it can use... so i can give it as ','... instead i am using some unique character that i can use such as '~'
 
7:52 PM
Right
Now we're getting closer because it's sounding like it's you that's searching for a delimiter that could have caused this in the first place
 
thats the reason i am trying to split and reassemble them with new delimiter..
 
Rewind a bit. Now I'm talking about how you're creating this data in the first place. You don't have to pick a delimiter that doesn't exist in the text in the first place
It's perfectly legal for a CSV file to contain a single field that contains a comma, for example
 
yes... but the aws glue service is splitting it based on say comma, and then placing it in a DB...
so it needs to be something unique unless i have missed something...
 
Then it isn't conforming to the CSV format. The likelihood of that is... not great
 
Proposal: base64encode all your data, and then it will be guaranteed to contain no commas and no quote marks. Now aws will be unable to mangle it.
 
7:58 PM
I don't know AWS Glue so I'm a bit stuck there, but I'm convinced this gets fixed in the writer and not the reader
 
What's there to fix though? That's perfectly valid csv, unless I overlooked something
 
"'2000-07-01 17:31:37",,"Making a great first impression without compromising the real you”: A conversation with manager, Firstname lastname",0,33,web,, is not valid
 
 
It has some apostrophe at the start, it's got unquoted commas and a semi-colon, and the quotes don't even end with the last bit of data
 
file = io.StringIO('''"'2000-07-01 17:31:37",,"Making a great first impression without compromising the real you”: A conversation with manager, Firstname lastname",0,33,web,,''')
reader = csv.reader(file)
print(next(reader))
# ["'2000-07-01 17:31:37", '', 'Making a great first impression without compromising the real you”: A conversation with manager, Firstname lastname', '0', '33', 'web', '', '']
Works fine
 
8:02 PM
Mmmm
That isn't how I think anyone would expect to have that parsed out
 
i haven't used io.StringIO.... let me give that a try... output wise it looks ok...
 
Well can you review that output first, please?
 
StringIO is just a substitute for a file
 
You now have a trailing ' going across multiple fields
It just looks odd. I don't think it's what you want. I was wrong that it wasn't possible to parse, but it really doesn't look like what I think someone would expect
 
The single quotes at the start definitely look out of place
@Vinod Is that the thing that imports your data into AWS?
 
8:08 PM
@Vinod Why not just use JSON if it's supported? That's a much more flexible format.
 
yes...
upstream output is csv... (API output)
 
And how is that saved?
Or even parsed, actually
 
@Aran-Fey.. I ran a quick check on one of the sample data... it seems to work as expected... Will do some more testing and get back if i still face more issues...
 
I love the '''"' in Aran-Fey's MCVE
 
8:53 PM
Is there some paradigmatic say to import a class into the global namespace? AKA make only the class show up rather than the whole module?
 
from module import my_class?
 
I can't wait for the signature Mikhail caveat :P
 
@Kevin been reading the Dark Tower series recently? :p
 
Nah just reminiscing
 
9:08 PM
weirdly... I've listened to Wizard and Glass in audiobook format recently
 
 
2 hours later…
11:29 PM
@AndrasDeak yeah it has to be dumped into global
for example, if you have an __init__.py and want to add a module
in __init__.py
from package.module import *
but
in __init__.py
from package.module.class import * ?
I think I can screw with .globals() and importutil but wanted something more paradigmatic
 
Are you trying to import the class or the functions in the class? What's wrong with from package.module import class?
 

« first day (3929 days earlier)      last day (1022 days later) »