Michael Horie(Ins) > Hi Rhett Dobson > Hi, was SSH'd in from home and got the message Michael Horie(Ins) > How is the assignment going? Rhett Dobson > Just wondering about the format, I was checking the tst_expected folder and saw some error messages Rhett Dobson > is the marking script looking for exactly those, or can we enter our own? Michael Horie(Ins) > The marking script is looking for exactly those messages Rhett Dobson > k. log3 is an error that says "Error: Found matching entry outside BEGIN-END pair. Terminating..." can you clarify what this means? Rhett Dobson > is it like an else case for the other errors? Michael Horie(Ins) > Yes, just a second. I'll copy in the relevant parts... Michael Horie(Ins) > Can't find the line right now Michael Horie(Ins) > Basically, Michael Horie(Ins) > these log files have duplicated ENDs or BEGINs Michael Horie(Ins) > Whenever that happens, you can just thrown an Michael Horie(Ins) > exception, and exit the program Rhett Dobson > the other errors seem to cover extra ENDs or BEGINs Michael Horie(Ins) > Let me just 2x check Michael Horie(Ins) > I wonder if Michael Horie(Ins) > there is data between and END and a BEGIN Rhett Dobson > it seems to me error #3 is an else case for other, weirder errors Rhett Dobson > that's a good example Michael Horie(Ins) > still checking...sorry Michael Horie(Ins) > found it I think Michael Horie(Ins) > line 1260 Michael Horie(Ins) > there are two records Michael Horie(Ins) > jumbled together Michael Horie(Ins) > so there are two dates, times, stationnames Michael Horie(Ins) > no END or BEGIN so that's why the error is generated Rhett Dobson > is that in one of the test input logs? Michael Horie(Ins) > Yes, log3 Michael Horie(Ins) > If you use vi Michael Horie(Ins) > type 1260G Michael Horie(Ins) > that get's you to line 1260 Johnny Wang >> has entered the room. Rhett Dobson > already found it in nano >_> Michael Horie(Ins) > nano will do, too! Rhett Dobson > okay, next question, it looks like the "sort by" parameter is the first line in the log Rhett Dobson > so the script uses one argument on the command line (the input file)? Michael Horie(Ins) > actually Michael Horie(Ins) > just a sec; running two chats concurrently Michael Horie(Ins) > for this assignment, Michael Horie(Ins) > everything is piped in via stdin Michael Horie(Ins) > so no command line argument is required Johnny Wang > will you be on campus tomorrow mr horie ? Rhett Dobson > oh, so that means > or < are used Michael Horie(Ins) > To Johnny: Sorry, schedule is too full; but I am available via e-mail or the occasional chat. Michael Horie(Ins) > To Rhett: Yes Johnny Wang > its ok. thanks Gurleen Tiwana >> has entered the room. Gurleen Tiwana >> has left the room. Gurleen Tiwana >> has entered the room. Michael Horie(Ins) > To Gurleen: to type, enter text into the lowest box on the screen Michael Horie(Ins) > and press the "enter" key or send button Gurleen Tiwana > i m stuck at assignment, unable to append Michael Horie(Ins) > Does it not append at all, or append in an unexpected manner Rhett Dobson > append is a method for list objects. make sure you're using a list, not a dictionary? Gurleen Tiwana > i mean the date , time ,... are not printed in an expected manner Gurleen Tiwana > yes i m Michael Horie(Ins) > Could you copy in a line of output text, please (not the source code, just the output) Johnny Wang >> has left the room. Michael Horie(Ins) > For that matter, make sure that you are appending valid data Michael Horie(Ins) > For example, group(0) should cause problems because it's 1 indexed Gurleen Tiwana > i tried Gurleen Tiwana > didn't work Michael Horie(Ins) > ok, just a sec Michael Horie(Ins) > So is your code following this pattern: Michael Horie(Ins) > phone = re.compile(r"^TEL;.*:(.*)$") line = sys.stdin.readline() while line != "":        result = phone.search(line)        if result != None:                print result.group(1) Michael Horie(Ins) > oops Michael Horie(Ins) > phone = re.compile(r"^TEL;.*:(.*)$") line = sys.stdin.readline() while line != "":        result = phone.search(line)        if result != None:                print result.group(1) Michael Horie(Ins) > phone = re.compile(r"^TEL;.*:(.*)$") Michael Horie(Ins) > line = sys.stdin.readline() Michael Horie(Ins) > while line != "": Michael Horie(Ins) >        result = phone.search(line) Michael Horie(Ins) >        if result != None: Michael Horie(Ins) >                print result.group(1) Gurleen Tiwana > i sent you my code in ur email Michael Horie(Ins) > Did you get my reply? Gurleen Tiwana > that mite help u to see where i m wrong Gurleen Tiwana > noo Michael Horie(Ins) > Has it arrived in your mailbox? Gurleen Tiwana > no... :S Michael Horie(Ins) > ok, I'll switch over to a00. watch your a00 terminal Gurleen Tiwana > wenevr i put group(1), it shows me error that no group exists Rhett Dobson > uhoh, I have 3 open Michael Horie(Ins) > Sorry Rhett, I was talking to Gurleen Rhett Dobson > just being silly ;) Michael Horie(Ins) > I need a bigger screen myself. I have about 10 windows open Rhett Dobson > I'm having a bit of trouble harnessing stdin though Michael Horie(Ins) > To Rhett: Ok, just a sec Michael Horie(Ins) > To Gurleen: No change on your screen ? Michael Horie(Ins) > To Rhett: What stdin issue? Michael Horie(Ins) > To Gurleen: In regards to group(1), make sure that the pattern your are matching against is using parentheses Michael Horie(Ins) > FOr example "PHON(E)=(/*)" Rhett Dobson > I'm just not sure what the syntax or usage is like. I'm trying to base my assignment off of the code from lab4 but it used a file input from the command line Kieran Sroba >> has entered the room. Michael Horie(Ins) > group(1) = "E", group(2) = phone number Gurleen Tiwana > ooooh i will give it a shot Michael Horie(Ins) > To Rhett: you mean in terms of getting it into python? Michael Horie(Ins) > ie from the command line Michael Horie(Ins) > or how to read from stdin within python Michael Horie(Ins) > cat tst_input/log1 | python wtrack.py Michael Horie(Ins) > for the former Michael Horie(Ins) > sys.stdin.readline() Michael Horie(Ins) > for the latter Kieran Sroba >> has left the room. Rhett Dobson > what was sys.std.readline() return? a string? I can't seem to print it or assign it to a variable Michael Horie(Ins) > should return a string Michael Horie(Ins) > try just putting print in front Rhett Dobson > maybe i'm just not familiar enough with python syntax, but I get errors with that >_> Michael Horie(Ins) > can you tell me what the error message says? Rhett Dobson > with the function in quotes I get Rhett Dobson > > import: unable to open X server `'. > import: unable to open X server `'. > ./wtrack.py: line 7: print: command not found Rhett Dobson > without quotes it's Michael Horie(Ins) > X server ... are you within Python or on the command line Rhett Dobson > ./wtrack.py: line 7: syntax error near unexpected token `(' ./wtrack.py: line 7: `print sys.stdin.readline()' Rhett Dobson > I run these from the command line Rhett Dobson > oh wait I noticed I have forgotten to include a path to python Gurleen Tiwana > use #! / bin/usr/python Rhett Dobson > isn't it /usr/bin/python Michael Horie(Ins) > what is the file name called? Michael Horie(Ins) > Since I am online right now, I can actually look at your file Rhett Dobson > looks like I just got it to work Michael Horie(Ins) > Good! Rhett Dobson > kind of embarrassing, skipping the first and most important line >_>; Michael Horie(Ins) > Happens to me as well Michael Horie(Ins) > The best way to code is in a team Michael Horie(Ins) > Catches more errors Michael Horie(Ins) > We'll actually talk about that later in the course Rhett Dobson > it prints a blank line afterward. I guess I won't worry about it though Michael Horie(Ins) > blank line could be a problem Michael Horie(Ins) > can break pattern match Michael Horie(Ins) > to get rid of it, use strip() Michael Horie(Ins) > "\n\n".strip() Michael Horie(Ins) > will remove trailing newlines from the Michael Horie(Ins) > preceding string Michael Horie(Ins) > ANy other questions? Michael Horie(Ins) > I'm getting hungry :) Michael Horie(Ins) > Need some supper Rhett Dobson > how would I target my stdin with that? put it on the same line as the print statement? Rhett Dobson > (me too actually) Michael Horie(Ins) > do you mean how to call it? not sure what you mean by target Michael Horie(Ins) > oh Michael Horie(Ins) > line = sys... Michael Horie(Ins) > then line.strip() Michael Horie(Ins) > or Michael Horie(Ins) > sys.stdin.readline().strip("\n") Rhett Dobson > it runs but hasn't removed the blank lines. maybe I'll try the other method Michael Horie(Ins) > print also add a \n Michael Horie(Ins) > try print "Hello" , Michael Horie(Ins) > the comma swallows the \n that the print issues Michael Horie(Ins) > the strip removes the \n that was consumed after reading in the first line Rhett Dobson > second method worked. comma is also a good tip David Minkley >> has entered the room. Kieran Sroba >> has entered the room. David Minkley > Dr. Horie, what is the easiest way to insert characters into a string? Michael Horie(Ins) > "a" + "second part" + "c" Michael Horie(Ins) > using the plus sign Rhett Dobson > what does strip() with no arguments do? David Minkley > I mean a string which already exists, ie: Inserting a 'p' into suer to make 'super' Michael Horie(Ins) > default is to get rid of newline Kieran Sroba > oki i dont understant the parnthesis to match and group indexed to one it keeps telling me that it cant find group one Michael Horie(Ins) > just a sec Michael Horie(Ins) > To David: I think strings are immutable. Not 100% sure, but pretty sure. So you would have to split the old string and then reassemble it Michael Horie(Ins) > Ti Kieran: I'll upload an example David Minkley > thanks Michael Horie(Ins) > upload button broken Michael Horie(Ins) > ok, line by line Michael Horie(Ins) > phone = re.compile(r"^TEL.*:(.*)$") Michael Horie(Ins) > so the () are used to declare groups Michael Horie(Ins) > here the characters following the : are placed into a group Michael Horie(Ins) > line = sys.stdin.readline() Michael Horie(Ins) > result = phone.search(line) Michael Horie(Ins) > so here the regular expression is applied to the string line Michael Horie(Ins) > if result != None: Michael Horie(Ins) > print result.group(1) Michael Horie(Ins) > and here the regular expression retrieves the first (and only) set of characters surrounded by parentheses Michael Horie(Ins) > so "h(e)(l)lo" would match e to group 1 and l t group 2 Michael Horie(Ins) > ...back soon...really hungry now, so looking for something edible around my desk Kieran Sroba > that makes sense and i got that to work but it wont append to my list Rhett Dobson > afk 4 food myself Michael Horie(Ins) > any error messages Michael Horie(Ins) > or just unexpected results Kieran Sroba > unexplained results... it will append my temp and my station name but not mthe date or the time David Minkley > how do you turn the keys of a dictionary into a list? Michael Horie(Ins) > To David: dict.keys() should return a list Michael Horie(Ins) > TO Kieran: What is your file name Michael Horie(Ins) > I can take a look at it online Kieran Sroba > its wtrack.py Michael Horie(Ins) > ok, just a sec David Minkley > thanks Michael Horie(Ins) > To David: You are welcom Michael Horie(Ins) > To Kieran: Could you do a :w Michael Horie(Ins) > To save the file? Michael Horie(Ins) > I think I am looking at an old version Kieran Sroba > did that work? Michael Horie(Ins) > 17 lines? Kieran Sroba > no its way more than that Michael Horie(Ins) > Could you save & quit, pls? Michael Horie(Ins) > Maybe that will save it to file Michael Horie(Ins) > yes Michael Horie(Ins) > just a sec Michael Horie(Ins) > make sure there are no group(0) lines left Michael Horie(Ins) > just a sec Kieran Sroba > there are group (0) but only for begin and end because i dont have a group one in those variables Michael Horie(Ins) > looking at your code now Michael Horie(Ins) > try setting currEntry to [] only when you come across a begin Michael Horie(Ins) > also, you probably don't want to assign a record to the dictionary until you come across an end Michael Horie(Ins) > end = END WRECORD I mean Kieran Sroba > but wont that chnage my indexing for my list Michael Horie(Ins) > the catch is that the order is not guaranteed Michael Horie(Ins) > so I see what you mean Michael Horie(Ins) > you could try reserving slots Michael Horie(Ins) > ie station name always goes into slot 1 Michael Horie(Ins) > or use a different data structure Kieran Sroba > but the order of the key's change not the keys themselves, so how do i set my key to always be the station name then append to my list Michael Horie(Ins) > not sure i follow. so if you read in "belmont" "feb 2" 10:00 59% humidity Michael Horie(Ins) > you want to do... Kieran Sroba > i want to set belmont as a key in the dictionary that has a list containing date time and number Michael Horie(Ins) > right, except that the date time & number may come after the station name, so Michael Horie(Ins) > you should not Michael Horie(Ins) > set a dictionary entry until you have Michael Horie(Ins) > all relevant data Michael Horie(Ins) > one thing that can be done as well Kieran Sroba > but either way if i put them into a list then set its key then put it into my dictionary it would still work right? Michael Horie(Ins) > is to keep track of the key in a separate variable David Minkley > I took out all /'s, :'s and _ David Minkley > 's from my date_time combo. Then sorted. How can I put them back in? Michael Horie(Ins) > just a sec Michael Horie(Ins) > to kieran: yes, that order is correct Michael Horie(Ins) > to david: i just left date & time as is Michael Horie(Ins) > you can use feb_02_10:00 as a key Michael Horie(Ins) > no need to do a numeric sort Michael Horie(Ins) > oops, I guess its 2008/02/02 instead of feb 2 Michael Horie(Ins) > same idea, though David Minkley > so we can assume the records will be given to us in date/time order? Michael Horie(Ins) > no, it could be time then date Michael Horie(Ins) > but once you have the two, you can put them together as Michael Horie(Ins) > a sort key David Minkley > sort key David Minkley > ? Michael Horie(Ins) > oops Michael Horie(Ins) > just replace that with "and sort them" David Minkley > okay, so sort can still handle it properly with the other characters included? Michael Horie(Ins) > yes David Minkley > well, that makes things easier... thanks! Michael Horie(Ins) > youre welcome David Ferguson >> has entered the room. Michael Horie(Ins) > back soon David Ferguson > Michael, I can't remember if the assignment is due Monday or Tuesday. Michael Horie(Ins) > Tuesday David Ferguson > Thank you Michael Horie(Ins) > you're welcome Michael Horie(Ins) > anybody else with a final question? Michael Horie(Ins) > ok, I'm signing off. I will check e-mail again tomorrow morning, and be online for a chat around 1pm tomorrow Michael Horie(Ins) >> has left the room. Kieran Sroba >> has left the room.