« first day (2684 days earlier)      last day (2489 days later) » 
00:00 - 17:0017:00 - 00:00

00:00
Idk, I'll leave it. I posted my regex equivalent as well.
@cᴏʟᴅsᴘᴇᴇᴅ I like this better
    i = df.groupby(['id', 'trigger']).cumcount()

    df.set_index(['id', i, 'trigger']).timestamp.unstack().assign(
        Diff=lambda d: d.ended.sub(d.started).dt.total_seconds() / 3600
    )
@piRSquared Yeah... trigger as the last column... will edit!
Oh, that lambda thing as well... will need to read up a bit to understand what's happening here.
no! that's preference.
but... basically, that lambda accepts the calling dataframe as its argument.
It was the deliberate placement of 'trigger' in anticipation of the unstack that I was referring to and you picked it up immediately.
At some point I have to stop messing with SO and get ready to leave on my plane.
00:29
I see.
Thanks, I definitely consider it an improvement. Safe travels!
ty sir.
00:49
@piRSquared I have that problem. Mostly I browse SO for questions when I'm putting off something else that needs to be done around my apartment.
01:01
@Code-Apprentice lol, I've been there (-:
Ok, that was the last one! I swear. Putting lappy in bag and calling for uber.
3
01:32
famous last words
What is the salad word for wow?
Anyway Numpy is very powerful.
01:47
I see why you said handling data is fun, you just need to know how to use the right tools.
Rhubarb all.
typo stackoverflow.com/q/48876717/4909087 (the issue was because of a blank line in their file)
02:09
@Airport waiting for flight.
02:29
@piRSquared Destination Seattle?
@cᴏʟᴅsᴘᴇᴇᴅ tagged
Yes, Seattle
 
4 hours later…
06:26
cbg
Just remembered that the first turtle graphics I played with, was via the "LOGO" programming lang. Fun times.
@cᴏʟᴅsᴘᴇᴇᴅ I've read your bio and see how you works and realized - "This person is the real !" — delinco 10 mins ago
heh
This is why I enjoy contributing here
user8605708
@cᴏʟᴅsᴘᴇᴇᴅ HAHA, HUMANS ARE VERY FUNNY I TELL YOU. THEY TICKLE MY HUMOR BONES. I AM ALSO HUMAN, HAHA.
user8605708
Hi, I'm new to Python. Could someone please explain where I'm going wrong in that code?
user8605708
Why is it invalid syntax?
06:36
@Blue The entire command gets dropped. Your function was never registered.
cbg all
In the interpreter, you need to have a line separation after your function block.
user8605708
@AshishNitinPatil Can you explain what you mean by "dropped"?
Just add an extra line after your function definition.
user8605708
@AshishNitinPatil Ah, okhay. How to add a line separation without pressing "Enter"? If I press Enter the code automatically gets executed
user9119815
@Blue Not sure, you can try SHIFT + ENTER
context for the robotic uppercase comment (reddit.com/r/totallynotrobots)
@AshishNitinPatil you don't say
:p
user8605708
user8605708
Thanks, it is working now
user8605708
06:42
'SHIFT+ENTER' does the job :)
Yeah, but that also executes the code first :-p (nothing different than regular ENTER)
It's kinda cute when an OP is trying to be sincerely appreciative of your help but doesn't know how best to express themselves.
@Blue Also, I assume you aren't supposed to use the builtin abs function ?
user8605708
@AshishNitinPatil Just realized that. Hehe.
user8605708
@AshishNitinPatil Yeah, I know. I was just learning Python, so for practice...
user8605708
06:45
Once I learn the syntax fully, I will built in functions
06:56
suppose i have a script myscript.py and before running it I want to kill any already running myscript.py
what should be a pythonic way to do it
I think there are at least a couple of questions on the main site for this
In Seattle waiting for train. 32/0 F/C
i can obviously do ps -ef | grep myscript then find pid and issue a kill command
@piRSquared Stay warm! Thermometer records 36F here.
07:25
have a question
i am using pandas to split a column into
spliting param is 'at'
df = pd.DataFrame(df.titles.str.split('at',1).tolist(),columns = ['titles'])
but there is one issue it splits like 'Director, Digital & Design Innovation, AMP Ltd.'
word Innovation into two Innov in one column and ation into other
it is working fine in Director Technology Services at Auriga Corporation in that case
any suggestions
... split(' at ', 1) ... ?
already did it thanks arne
Good morning all! I have an encoding issue. I am reading data from a pymssql database. However my swedish characters look like this: u'D\xf6rrtrycke Vit'.
Anyone know how to convert the characters back to åäö?
I got the utf-8 header details and I have tried to decode with utf-8 but it doesn't seem to do the trick. I am using Python 2.7 btw.
07:40
@sockevalley You'll have to figure out what encoding the database version of the text has.
If it was indeed UTF-8 you'd see the expected output.
When I know the encoding of the database, should I decode or encode the string accordingly? @AshishNitinPatil
07:54
>>> "😃'".encode()
b"\xf0\x9f\x98\x83'"
>>> "😃'".encode().decode('utf')
"😃'"
>>> "😃'".encode().decode('utf-16', 'ignore')
'\u9ff0莘'
Basically, ff you give the wrong encoding, you may see different results (or errors).
So yeah, be consistent with your database reads & writes.
If you write with some encoding, make sure you read with the same.
@sockevalley And try to move to python 3, if possible
string IO in 2 is the worst part of python
(imo)
The encoding is utf-8 by default, so changing the encoding also works: "😃'".encode('utf-16').decode('utf-16', 'ignore')
The encoding and decoding codecs need to align
cbg
cbg
08:05
@AshishNitinPatil I managed to change the charset for my database to utf8 now. I also checked getdefaultencoding() with sys and it said that I had ascii, even though I specified utf-.8 in the header.
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe5' in position 2: ordinal not in range(128)
08:23
What's the difference of printing like print("hello" + u'D\xf6rrtrycke M\xe4ssing Matt') and
print("hello", u'D\xf6rrtrycke M\xe4ssing Matt')?

When use + it concatnates the strings and the åäö can be printed. But when I use the comma it can't print out the åäö chars lol
@sockevalley can't reproduce (in Python 2.7 as well as Python 3.5+)
You are likely missing u in front of the string (required in Python 2.7) which tells Python to treat the string as a unicode string (which has default encoding as UTF-8)
a unicode or an unicode? It seems grammatically wrong but pronunciation feels okayish.
That ought to be the main reason, ty for the help @AshishNitinPatil
It's official... I've refused to answer the last 1000 posts that I've been aware of that have "excel" or "xlsx" in it! I want my cookie!
@AshishNitinPatil a/an decisions are based on phonetics, so if you hear a 'y' in front of it, which is considered a consonant in english, it goes with 'a'
08:36
@piRSquared 🍪
those are perfect. Thank you both
=)
@Arne yeah, I knew that but somehow didn't conclude with the phonetics of "U"nicode sounding like "YOU"nicode.
thanks though
@cᴏʟᴅsᴘᴇᴇᴅ come on the voting on my answer should not be 4. that's because the other two posters /glare refused to upvote each other.
08:38
i am not even sure if there is a single english word that is pronounced with an actual u at its start
oh, 'uppercut' is
@Arne that's an understatement!
ah, almost faster than you :p
maybe should have spent a couple more seconds thinking before writing that :p
stupid reply button...
@piRSquared I'm more interested in why the question has low upvotes. It's so well written.
@piRSquared I don't upvote their posts because they're not in the habit of upvoting anyone else's either >:(
Also, piRSquared's is more interesting, hence the "more" upvotes I suppose.
I was thinking about gaming his response... I should have. I was going to upvote his and not yours prior to posting. Seeing if he'd reciprocate. If he did, then I'd upvote yours and post.
I think we get some time to reverse our upvote, so you could try that (sportmanship) next time :-p
It would've ended as you'd expect :)
At least OP had the sense not to select my answer
I would've been fine with it either way. Satisfied enough that 3 people found the answer "useful"!
08:46
@cᴏʟᴅsᴘᴇᴇᴅ An upvote doesn't have to come because an answer is helpful, not always I mean. I don't spend all my limited upvotes daily, so am free to expend them on beautiful answers / questions :)
I like posting useful stuff but sometimes a clear decision can be made. On several occasions I've lobbied OP to deselect my answer for another one.
Hopefully those Q&As are as useful as they are beautiful ;D
Each question has a story. And each answer has a lesson.
But your vote is your vote, it's up to you to use it as you please
@AshishNitinPatil that is beautifully said.
08:49
Thought I'd try extending the olive branch... and they reciprocated... guess small miracles do happen from time to time :)
@cᴏʟᴅsᴘᴇᴇᴅ In a utopian world, that's just the usual thing to do.
Sometimes I love posting just to demonstrate a concept as opposed to trying to present the best answer
there's that "a utopian" thing again
English is a weird language.
an!
amirite?
08:51
before that big cookie image
Hi Friends,
I am unable to plot the area chart in bokeh for some reason..

Below is the code used for the same..
from bokeh.charts import Area, show, output_file

# create some example data
Areadict = dict(
I = df['IEXT'],
Date=df['Month'],
O = df['OT']
)

area = Area(Areadict, x='Date', y=['I','O'], title="Area Chart", legend="top_left",
xlabel='time', ylabel='memory')

output_file('area.html')
show(area)
Writing out-of-the-box answers is a talent that comes with years of experience and a deep understanding of the language
You know what... English is wrong
All i see the date getting plotted , but no charts there
@piRSquared yes it is!
08:55
@piRSquared I'd rather call it 'very dynamic'. One of the downsides of having comparably few rules
Would this classify as an out-of-the-box answer? (I'm guessing not, in which case I'd be interested to see one that is)
I'll tell you what is out the box... OP's presentation of a dataframe
But I liked the answer. I'd say yes
I dont want to post it as a question, it could be too silly of me perhaps..
@asimo My personal philosophy (not the opinion of the room):
There are such things as stupid questions, but you have to be brave enough to ask them anyway.
My life is riddled with stupid questions and a few gems.
Haha
That is a pretty deviant way of representing a dataframe
09:04
@piRSquared I have posted the question on the portal
@asimo Just in case it is something that was stopping you (because it sure stopped me back inthe day): getting closed because a duplicate exists is a good thing. You probably get a high quality answer, and stackoverflow gets a higher coverage of for generalizable problems
I don't know if I should convert my comment to an answer here - stackoverflow.com/questions/48881296/…
I have cv-ed it as simple error, but not sure if that's correct
@AshishNitinPatil yes and yes (-:
rbrb for a bit
@Arne Cheers :)
09:24
@Blue please post text rather than images of text
@AshishNitinPatil this actually came up a few days ago, Moo got unsure if I recall correctly
10:10
I was trying to compute the hadamard product of two numpy matrices using * for the longest time, wondering why it wasn't working until it hit me and I facedesked
grr, why people use that API in mcves is beyond me
Cabbage
@cᴏʟᴅsᴘᴇᴇᴅ done
Thanks :) Closed as a dupe of an rtfm canonical
That question is in a very gray area between typo and I-have-no-idea-what-I’m-doing
and I-don’t-believe-you-followed-the-answer-properly
@AshishNitinPatil Or a tool request?
@cᴏʟᴅsᴘᴇᴇᴅ well if their actual case is a matrix they're right to use it...
of course if it's unrelated I could see why it hurts, but that's mostly "doesn't know better"
I mean, whether that's their use case or not is irrelevant to the fact that that API sucks, right
Of course but you were complaining about the use of the api in an mcve :P
@cᴏʟᴅsᴘᴇᴇᴅ tagged
11:20
I was lamenting its use in MCVEs because it sucks :D
Thanks Ashish, hammered
rbrb sleepy time
@cᴏʟᴅsᴘᴇᴇᴅ I think its use in actual code is a much larger problem :D
This is an interesting question... @MartijnPieters care to take a stab?
@AndrasDeak Yup... the fact that it appears in MCVEs would imply its prevalence in production code too >:(
rbrb to all.
11:51
it's not deprecated obviously enough, alas
rbrb
12:41
Cbg all!
13:20
Game chat. I played 20 hours of The Witness over the weekend. It's very good if you like logic puzzles.
With zero lines of dialogue or explanatory text (with one optional exception), the game revels in being cryptic. The strategy guide on IGN doesn't even know what the requirements are to 100% complete the game. "If you find out what happens when you [verb redacted for spoilers] all [number] [thing]s, let us know"
🙄
"... when you reticulate all of the splines, let us know" ?
Personally I have [verb]ed only about 5% of the [thing]s and I'll probably say "ok that's enough" after doing only the low-hanging ones
My primary complaint about the game is a series of puzzles that require you to gather clues from environmental sounds. I'm pretty tone-deaf so I had to google solutions for those ones.
Maybe I should have checked the options menu to see if they had accessibility options for the hard-of-hearing. That's the kind of thing that woke game devs like to implement for social justice points these days, right?
(Which is not to say that accessibility options have no value other than being exchangeable for social justice points when you implement them. But that's probably their primary value for lawful evil developers)
13:39
as long as these kind of logic puzzles do not have options for people who are bad at logic (such as me), they got no accessibility sj-points from me.
@Withnail is here
cbg o/
Ahoy?
@Withnail just a hi, matey
13:40
Almost certainly the solutions for 99% of the puzzles are available online. One optional area can't be googled because of the nature of its puzzles.
So far, Tuesday has been a tyre fire.
inherently suspicious of everything
And i've been relocated to a desk in the middle of our office next to a glass wall.
So, that can dive off a building head-first, too.
How are you doing? How is everyone today?
@Withnail it is slang for mess?
A tyre fire?
@Withnail yep
@Withnail microsofting
@Kevin I read mixed reviews about it, I'm on the fence
13:43
yeah, like... a disastrous day, slow-burning and hard to put out. Noxious.
I, too, was on the fence, until the price temporarily fell to six dollars during a weekday sale.
@Withnail hate those kind of days
I was ready to flip desks by about 10:30 GMT
By my value-of-entertainment-hours metric, I would only need to be amused for 40 minutes for it to be worth it at that point
13:44
so would you overall recommend it?
> It's very good if you like logic puzzles.
nevermind
Is it $10/hour you benchmark against?
@ZackTarr Cabbage
oh, also it was windows-only :|
I was talking to someone about that the other day, Kevin
@Withnail More like 9$.
13:45
How'd you arrive at that, out of curiousity?
What do you think Kevin does when he's not entertaining us?
Because I'm willing to spend approximately 18$ on a two hour movie plus candy/soda.
putting a price tag on everything, from his fun time to human lives of various stages of health and age
Lately I've been thinking I should add more granularity to my metric because in truth I'm willing to spend 9$ on good entertainment, not just something to pass the time. Like... I put sixty hours of time into Zelda, but it wasn't worth $540, because it was like 10 hours of sublime entertainment, 30 hours of good entertainment, and 20 hours of just barely engaging fetch quests and/or ingredient hunting
cabbage fellas
Does this look right to anyone?
13:50
And a decidedly nonzero amount of loading screens.
@Kevin Games start charging per the amount played would be scary
Ah, cool. that makes sense.
@Anarach I'd expect that to give a syntax error because you can't use numbers as keyword arguments.
>>> def f(**kwargs):
...     pass
...
>>> f(1=2)
  File "<stdin>", line 1
SyntaxError: keyword can't be an expression
It gives a syntax error
Oh, word? ;-)
13:51
@Kevin Wow Yes..
I think I've paid about 2 pence per hour for Kerbal, going on the hours-played metric.
is there an intentional missing closing parenthesis inside the string in the Template?
@Kevin So should I remove the Ints
Yes, but then the question is: what to replace them with? Because you can't just remove all those arguments and still expect all the substitutions to take place.
I know nothing about DB interfaces in Python so I have no specific advice there.
@Kevin Yeah.. Have to do some thinking
13:54
Also I agree with Andras that the query string needs another paren
a query that only works with code injections
you should also consider introducing line breaks, because those lines are horrible
rhubarb for a while
Ya.. I should probably
Thank you guys
@Kevin Oh man, that fuzzy logic course I took might come in handy to calculate an appropriate money-> fun/time function
Might be the first time in this millenium that that field of study is actually useful for something
Super hard mode: account for the effect where the tenth bite of a steak is less satisfying than the first bite, even if they're objectively the same
Doing it wrong
the last forkful of any meal should be the best forkful, with ingredients saved to make it so
correct ratios of protein to BCBs
14:05
time is just another dimension, won't hurt when we already have 20 others in there
including BCB ratios
@Withnail I like cereal for that reason because the milk becomes linearly more enjoyable as it slowly becomes a milk-sugar-cinnamon solution
Five cent ramen noodles also tend to end with an MSG explosion if you drink the broth at the end
Omg. I really want cinnamon Grahams from the 90s now
they don't taste the same as they used to.
Based on zero evidence I'm going to blame that on the declining prevalence of pure cane sugar in foods
Or taste buds aging
^
the sad truth
14:13
You'd imagine that you'd get more susceptible to sugar though? my kid can eat a volume of sugar that'd make me vomit
More susceptible gut, less susceptible tongue
oooh, JupyterLab is "ready for daily use" now, exciting!
A recent question had code containing the line While True:. I pointed it out and OP replied "I changed it, but the outcome is still the same: The code prints 23 instead of 42". Meanwhile I'm like:
Oh yeah? Your code which was not valid Python and would not have run even a single statement before crashing was outputting 23?
OP, buddy old pal, our relationship cannot stand on a foundation of lies
As karmic punishment for his deception, half of the answers he got were useless variations on "replace While with while"
14:31
I'm sure one of those will end up getting accepted
Fun fact, the original name of the doubt option in LA Noire was force, which explains the sometimes surprising intensity of Mr. Cole when you chose it.
\o wet cbg
Unfortunately the only force available to me is uploading scathing memes
Devil's advocate: what OP meant to say was "Oops, that was a transcription error when copying my code into the post, and obviously since no change has been made to my actual code, it continues to produce the same output it always did, which was never a SyntaxError stack trace"
"I changed it" is technically true if "it" means "the post but not the code" and "the outcome is still the same" is also technically true. It's just wildly misleading when those sentences are next to one another
And it violates the unspoken assumption we charitably give to all questions, which is: the code you posted is the code you're running
(Has there ever been an assumption that's violated more often? It's up there in the big leagues along side "I before E" )
Physicists claim that free energy devices are impossible, but that's only because they've never tried constructing one in a grocery store and insisting to the exasperated clerk that it will absolutely work
14:47
How do you guys handle Homework question like this? Do them? Push back? Close?
This turbine is powered by my own ignorance, and if the label on this creamed corn doesn't scan, it must be free. [RPM steadily increases]
DSM
DSM
Morning thermodynamic cabbage for all.
@ZackTarr I just ignore the part that says it's homework. This one I might be inclined to downvote because it's low-effort; I would do so even if it was asked out of idle curiosity.
Fair enough. I found a post on meta talking about the community's split attitude towards homework questions and figured Id ask what the python community goes by. But yeah I figured since it was low effort. Likely you could call it a dup.
The only time I take homeworkness into consideration when judging a question is when I read it and think "why would you want to do this ridiculous thing?". People that insist on doing something the dumb way get my scorn, but people forced to do something the dumb way because of their dumb professor get my pity
14:51
Probably a question out there asking about while loops somewhere.
DSM
DSM
Sometimes there's real merit in requiring people to do things manually, though. In real code, you'd use groupby. But if you don't know how to implement groupby on your own, how good a dev can you be? So it makes sense to assign questions involving doing things the "dumb way" sometimes.
Yeah I'm being a touch uncharitable by calling a professor dumb if he requires the student to write un-idiomatic code, even for illustrative purposes
You have to know how the dumb way works to know why not to use it Im sure.
It's a very "I know it when I see it" situation where I sniff out whether the assignment is stupid or if it's analyzing the nuts and bolts of CS theory
15:07
Is it well-defined that accessing a method will always return the same bound method instance? i.e. instance.method is instance.method is guaranteed to always be True? Can't find anything about this detail in the docs
DSM
DSM
Was that ever true?
I think the room discussed this a long time ago and the answer was "no, for example in this case: [...]"
But I can no longer remember what case that was.
DSM
DSM
I'm pretty sure I've never relied on it being true, at any rate.
I can imagine it being useful to maintain identity in that way. For example, Tkinter has a bind method for registering callbacks, and an unbind method that un-registers a callback if you pass it the original callback.
If myAppInstance.onButtonClick changes each time you access it, it's going to be hard to unregister
Ah, I tested it wrong.
>>> id(a.foo)
139682133555720
>>> id(a.foo)
139682133555720
>>> a.foo is a.foo
False
it re-used the same memory :I
15:10
My work here is done
Hmm, if is fails for even simple cases, I'm curious how unbind works as often as it does. You'd think we'd see a lot of "why isn't unbind working?" dupes in the Tkinter tag, but we don't.
DSM
DSM
Maybe you only need equality.
Ah, if equality works on bound methods even if is doesn't, that would explain it.
DSM
DSM
In [26]: x,y = Fred(), Fred()

In [27]: x.a is y.a
Out[27]: False

In [28]: x.a == y.a
Out[28]: False

In [29]: x.a is x.a
Out[29]: False

In [30]: x.a == x.a
Out[30]: True
Radical.
Lesson: when implementing your own callback system, don't use is.
DSM
DSM
15:15
Lesson: when implementing your own callback system, don't use is.
DSM
DSM
"Didn't I?"
"My job here == done" FTFY
DSM
DSM
Nice.
/me flips cape dramatically and exits
15:25
Can anyone help me explain anything on this guy's question. I tried to nudge him in a direction but he wants code as an example, and I cant figure out his code on scraping the data.
Update: my d&d character got the green light from the DM but he says "thematically we're more south-of-the-Mediterranean so unless you explicitly want to portray yourself as 'that guy from the exotic north countries', try to rework your backstory with less Greek/Roman/Norse and more Egyptian/Arabian/African" and now I'm seeking a Cliff's Notes for the classical myths from those regions
oh, i had wanted to write something about it, but lost track.
DSM
DSM
while s <> None: <- something tells me the python-3.x tag might not be appropriate.
Oh, plus the u prefix, but I saw <> first.
DSM
DSM
Ha! It's not just me who does that!
15:37
The top in the wrong window?
DSM
DSM
Commands in general in the wrong window. I'll go months without wrong-windowing it and then do it twice the same week.
I was just wondering why my machine's fans were going.
Firefox, so probably some yam is mining crypto in my browser.
15:49
Augh, the hacky data file parser I was writing fails because I assumed every entry was on its own line but actually some entries take up multiple lines
Each entry is a tab-separated collection of strings, some of which may contain newlines. Each entry is separated by a newline. Some entries have more strings than others.
A \t B \t C
D \t foo
bar
baz \t E
F \t G

Should separate out to

[
    ["A", "B", "C"],
    ["D", "foo\nbar\baz", "E"],
    ["F", "G"]
]
@Withnail about:performance
morning cbg
DSM
DSM
Cabbage for the apprentice.
I think I can guarantee that no entry has more than one string that contains a newline, which makes this less of a nightmare
15:59
@Kevin Is there a reason you are not using this?
DSM
DSM
Yeah, if neither \t nor \n specifies the start of a new line, you're in an unhappy situation.
Firefox about:performance may be slowing down your computer FML
well there's your problem
:D
Oh it's decided that it's now SO chat, and aws console
I'd like to note that I fully agree with Kevin's eloquent assessment of his stance on homework questions
16:00
which I buy the latter of, certainly.
I don't have full control over the formatting of the input data. I'm getting it by copying the contents of the Errors&Warnings tab in Visual Studio and pasting it into Notepad.
So "just output it in standard CSV notation" would require me to infiltrate Microsoft's VS team
Well i mean, if you're going to do a thing, do it properly eh? Ski mask on...
The jupyterlab announcement gives me a tl;dr that jupyterlab is now live, but it doesn't give me a tl;dr of what jupyterlab is. Oh well.
Possibly there is an already-existing "export to [excel/CSV/whatever]" button that I'm blindly overlooking
Quickly scrolling through the input file, I see that at least 99% of entries all have the same first string of "Warning". Since this is the Warnings&Errors tab, I suspect that value will only ever be "Warning" or "Error". So maybe I could use that to determine the start of new entries.
But on the other hand, if any other strings in an entry are also "Warning" or "Error", then it will incorrectly split one entry into two. And maybe the first string could be "Info" or "Fatal" or something, but only 0.001% of the time, and I just didn't see it with my imperfect human eyes.
16:07
cbg
Most of the answers at stackoverflow.com/questions/5040571/… are just variations on "just copy and paste it" and do not address the problem of multi-line entries.
Ooh, a deleted answer says "you can write a plugin to do this" and links to dotnet-magic.blogspot.in/2012/12/…;.. Except that page says "Sorry, the page you were looking for in this blog does not exist.". Damn you, link rot!
Ah, every entry has the same number of strings, although some of them may be the empty string. I thought it was otherwise because I was stripping where I shouldn't.
Warning! Do not read @Kevin's posts starting halfway through "because I was stripping where I shouldn't."
6
Which means I can deterministically separate entries except for the first and last one on each line.
For example, given that each entry contains three strings,

A \t B \t C
D
E \t F \t G

Can be parsed as

[
    ["A", "B", "C\nD"],
    ["E", "F", "G"]
]

or

[
    ["A", "B", "C"],
    ["D\nE", "F", "G"]
]
I know with complete certainty that B and F are where they should be. Fortunately, all the data I'm actually interested in, is in the middle of each entry, so it's not a huge deal if I guess wrong for the first and last strings.
16:27
Hello people! I'm facing the error - requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
on Mac macine
I've been struggling with this the whole day
any help would be really helpfull
here is the full trace :
File "/Users/saraf/Documents/Projects/PyCharmProjects/IGT/igt/igt/utils/RestAPIClient.py", line 48, in put
raise e
File "/Users/saraf/Documents/Projects/PyCharmProjects/IGT/igt/igt/utils/RestAPIClient.py", line 42, in put
, auth=self.auth)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/api.py", line 123, in put
return request('put', url, data=data, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/requests/api.py", line 56, in request
16:44
re.findall("[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*\t[^\‌​t]*\t[^\t]*\t[^\t]*\t[^\t]*\n'", raw_data) gets me the data I want, I think
47 mins ago, by Code-Apprentice
@Kevin Is there a reason you are not using this?
I've used python's csv module with comma delimited data, and it handled new line characters just fine.
even ones that were inside of values
The data isn't CSV, though. Or any deterministically parseable variant of CSV.
I expect it would work with tab delimited data as well.
I'm sure csv can parse a\t"b\nc"\td but I'm doubtful it can parse a\tb\nc\td the way I want
Even though the library is called "csv", you can specify a delimiter.
would be worth taking a few minutes to try it
16:49
The problem isn't the delimiter. The problem is that it doesn't use quote marks around values that might contain internal separator characters
I do agree that "play around with csv for a while before resorting to writing your own solution" is excellent advice in the vast majority of cases. It's an unusual circumstance that I can formally prove my data format is ambiguous just by eyeballing it
import csv

with open('input.csv') as f:
  reader = csv.reader(f, delimiter='\t')
  for row in reader:
    print(row)
you really should assume that Kevin knows what he's doing
['A', 'B', 'C']
['D']
['E', 'F', 'G']
he usually does
oh...that probably isn't what you want...
16:56
when it comes to programming, anyway :P
I was writing an example to see how it handled that input ;-)
import csv

with open('input.csv') as f:
    print(repr(f.read()))

with open('input.csv') as f:
  reader = csv.reader(f, delimiter='\t')
  for row in reader:
    print(row)

#output:
#'A\tB\tC\tD\nE\tF\nG\tH\tI'
#['A', 'B', 'C', 'D']
#['E', 'F']
#['G', 'H', 'I']

#desired output:
#'A\tB\tC\tD\nE\tF\nG\tH\tI'
#['A', 'B', 'C', 'D']
#['E', 'F\nG', 'H', 'I']
Sorry to switch around the input data, but here's one that demonstrates the ambiguity better. I want each line of output to have the same number of elements.
DSM
DSM
Minor: newline=''
00:00 - 17:0017:00 - 00:00

« first day (2684 days earlier)      last day (2489 days later) »