Re: extract string
Zhao, I am really busy right now, so I have not read all of the responses to your problem completely, but I did notice this: [EMAIL PROTECTED] said: You said that there is an extra column in the 3rd line. I disagree with you from my perspective. As you can see, there are 3 commas in between jesse and Dartmouth college. For these 3 commas, again, if we think the 2nd one as an merely indication that the value for age column is missing, then the 3rd line will be be read as [jesse, MISSING, Dartmouth college], not [jesse,empty,empty, Dartmouth college] as you suggested. A lot of these textual commands depend on the concept of a field delimiter. In your first example, it seemed clear that a possible field delimiter was the comma (,), and so if you saw two commas together, it represented an empty field. Not a missing field, because the field was technically still thereit just had NO data in it. When you included the line: jesse,,,Dartmouth college and claimed that the middle comma represented a missing age, to a textual based scanning program that has been told that the comma is a field separator means that there are now four fields in the line, not just three. If, from the beginning, you had shown that you meant for the comma to be used both as a delimiter and as a piece of data, then a lot of the answers would have been completely different (and probably considerably more complex). md -- Jon maddog Hall Executive Director Linux International(R) email: [EMAIL PROTECTED] 80 Amherst St. Voice: +1.603.672.4557 Amherst, N.H. 03031-3032 U.S.A. WWW: http://www.li.org Board Member: Uniforum Association, USENIX Association (R)Linux is a registered trademark of Linus Torvalds in several countries. (R)Linux International is a registered trademark in the USA used pursuant to a license from Linux Mark Institute, authorized licensor of Linus Torvalds, owner of the Linux trademark on a worldwide basis (R)UNIX is a registered trademark of The Open Group in the USA and other countries. ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Emacs PINE -- perfect together. [Don't hurt me!]
A sad, sad truth that I've come to accept is that I have PINE's keystrokes emblazoned in my memory. I use it at least once a year, whether I need to or not, and I never even have to pause. They keystrokes are just THERE. I tried MUTT. No dice. Never was a big ELM fan. And GUIs are certainly nice, but sometimes text based is the way to fly. Ironically, however, I really hate PICO. Another sad, sad truth is that you failed to mention MH even though it predates all those upstarts. I'm using it right now and have been for about 15 years (I mean, for all my email in all that time, not just this one tedious message ;- ). I prefer to use it from the command line (each verb is actually a distinct program, each message a distinct file) but it also has a decent GUI named EXMH coded in Tcl/Tk, and support for all the pointless MIME-wrapped, armored, translated, encrypted, GIF-augmented, HTML-encoded glop with attachments and rotating knives that clutter email messages nowadays, if you happen to like that sort of stuff... ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract string
-- Original message -- From: Zhao Peng [EMAIL PROTECTED] Hi All, Kenny, your grep univ abc.txt | cut -f3 -d, | sed s/\//g dev.txt works. I mis-read /\ as a simliar sign on the top of 6 key on the keyboard(so when I typed that sign, I felt strange that it is much smaller than /\, but didn't realize that they just are not the same thing), instead of forward slash and back slash. I felt really embarrassed with my stupid mistake. //blush It happens. Believe me, I have done much dumber things in my time :-) Kenny, regarding missing column issue, let me try to explain it again. Below is quoted from my original post: [SNIP] You said that there is an extra column in the 3rd line. I disagree with you from my perspective. As you can see, there are 3 commas in between jesse and Dartmouth college. For these 3 commas, again, if we think the 2nd one as an merely indication that the value for age column is missing, then the 3rd line will be be read as [jesse, MISSING, Dartmouth college], not [jesse,empty,empty, Dartmouth college] as you suggested. This poses an interesting problem. The , is being used for two purposes: a delimiter *AND* as a place holder. Unfortunately, cut and the like will see it as a delimiter and only a delimiter. It's what they do. I think that you may need to use the awk line that I sent, or some of the perl one-liners to get just the last column. Otherwise, you will end up with emty fields. For one particular variable(column) called school, the length of some of its value is quite long(like: Univ of Wisconsin at Madison, Health Sci Ctr), but I don't know the definite length. I need to know it, because if the length I specify it not enough, only partial values will be read. Many of its values contain univ, so I just thought if I could extract all strings containing univ from that variable(column), I will have a better chance to figure out the length of school. That's why I had this question. This is going to be another problem. Every , that is used is going to be seen as a dilimiter. If the school name has a , in it as there is between Madison and Health above. That means that taking just the last field will not work either. I think that the easiest thing to do in this case is to change the delimiter to something that is unlikely to be found in any of the columns, like a :. C-Ya, Kenny ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Emacs PINE -- perfect together. [Don't hurt me!]
On Wed, Jan 11, 2006 at 01:30:50AM -0500, Ken D'Ambrosio wrote: So I've set up Emacs as my default editor. Nice. But the one problem I have is that I'd really like to have Emacs do column-77 wordwrap if -- and only if -- it's invoked from PINE. I have zilch idea how to invoke this from the command line, and don't know enough about Emacs (I dabble, I don't use) to do it any of the other ways. Suggestions on which approach? I've Googled, to no avail, but I know that there are some Emacs die-hards out there, and would be glad to follow their sagacious advice. set your pine editor to pineedit which would be a shell script like this: #!/bin/sh touch $1 chmod 600 $1 exec emacsclient options for text wrapping $1 Where emacsclient is whatever form of emacs invocation you need for your environment, like are you in X-windows? Do you want Xemacs or do you want an xterm with emacs running in it.. etc... -- Jeff Kinz, Emergent Research, Hudson, MA. speech recognition software may have been used to create this e-mail The greatest dangers to liberty lurk in insidious encroachment by men of zeal, well-meaning but without understanding. - Brandeis To think contrary to one's era is heroism. But to speak against it is madness. -- Eugene Ionesco ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Emacs PINE -- perfect together. [Don't hurt me!]
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ken D'Ambrosio wrote: | ... | So I've set up Emacs as my default editor. Nice. But the one | problem I | have is that I'd really like to have Emacs do column-77 wordwrap if | -- and | only if -- it's invoked from PINE. I have zilch idea how to invoke | this | from the command line, and don't know enough about Emacs (I dabble, | I don't | use) to do it any of the other ways. First, switch to the buffer you want to word-wrap at column 77. Then do the following commands. M-X auto-fill-mode ^U77M-Xset-fill-column If you mean by from the command line, that you want something to feed to emacs on the bash command line (vs. the Emacs internal command line), then *I* would use the following on the emacs command line: - --eval=(progn(auto-fill-mode)(set-fill-column 77)) outgoing.txt But it doesn't appear to work. Anyone have any ideas? (I suspect the 'eval' is done before the file is visited, but I'm not sure.) - --Bruce -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDxRG4/TBScWXa5IgRAl5DAKDBWWU1sltEpeDHU2DmiBAmtxz0FgCgqfY+ Y/6DD2Vg91RHNhhHzWVU2Dc= =r9vn -END PGP SIGNATURE- ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Homework problems
Travis Roy [EMAIL PROTECTED] writes: Not having a degree, some of my best information has come from places like this and other sources on the internet. I have a degree, two in fact. Most of *my* best information has come from places like this and other sources on the internet. (the rest comes from RTFM and the daily GNHLUG-sponsored Ask Ben Scott show ;) -- Seeya, Paul ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Emacs PINE -- perfect together. [Don't hurt me!]
On Wed, Jan 11, 2006 at 08:50:13AM -0500, Jeff Kinz wrote: On Wed, Jan 11, 2006 at 01:30:50AM -0500, Ken D'Ambrosio wrote: So I've set up Emacs as my default editor. Nice. But the one problem I have is that I'd really like to have Emacs do column-77 wordwrap if -- and only if -- it's invoked from PINE. I have zilch idea how to invoke this from the command line, and don't know enough about Emacs (I dabble, I don't use) to do it any of the other ways. Suggestions on which approach? I've Googled, to no avail, but I know that there are some Emacs die-hards out there, and would be glad to follow their sagacious advice. set your pine editor to pineedit which would be a shell script like this: #!/bin/sh touch $1 chmod 600 $1 exec emacsclient options for text wrapping $1 Where emacsclient is whatever form of emacs invocation you need for your environment, like are you in X-windows? Do you want Xemacs or do you want an xterm with emacs running in it.. etc... To set your editor to something non-default in pine do this: The default editor for Pine is Pico, but you can change this to Emacs or vi by following the steps below: 1. At Pine's Main Menu, press s for Setup, then c for Config. 2. You will see a long list of configuration options. Use your arrow keys to find and highlight enable-alternate-editor-implicitly. Press Enter so that there is an X in the box. 3. Use your arrow keys to find and highlight editor = No Value Set. 4. Press a for Add, and enter the name of the editor or the path to the script you wish to use. 5. Press e for Exit Config. When prompted, press y to save your changes and return to Pine's Main Menu. -- Jeff Kinz, Emergent Research, Hudson, MA. speech recognition software may have been used to create this e-mail The greatest dangers to liberty lurk in insidious encroachment by men of zeal, well-meaning but without understanding. - Brandeis To think contrary to one's era is heroism. But to speak against it is madness. -- Eugene Ionesco ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Homework problems
(the rest comes from RTFM and the daily GNHLUG-sponsored Ask Ben Scott show ;) He needs a better co-host.. and the show band sucks ;) ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Homework problems
Christopher Schmidt [EMAIL PROTECTED] writes: (I think I'm supposed to call you Hitler now or something. Godwin told me that once.) I think you have to start with Nazi, and it escalates up from there to Hitler. Christopher Schmidt Web Developer -- Seeya, Paul (who remembers when Web Developer was a derogatory term ;) ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Boston Linux Meeting Wednesday, January 18, 2006 at 7:00 pm
When: January 18, 2006 7:00PM (6:30 for QA) Topic: Free and Open Source Software: Reaching for the Stars Moderator: Jon maddog Hall - maddog li org Location: MIT Building E51 Room 315 Maddog talks about his travels around the world visiting Linux users. For more than a decade Jon maddog Hall has been traveling around the world talking about Free and Open Source Software. He has experienced software users from the island of Fiji to the depths of the Amazon rainforest to the depths of far behind what was the iron and bamboo curtain all using FOSS. Come here the stories of what these people were doing with it, why they chose it and why the things they did would simply have been impossible to do with closed source, proprietary software. Liberal use of his many photographs taken over the years will be applied to the talk. Additionally, we will have a visitor from Kuwait who is forming a Linux user group in Kuwait. Husain Al-Bustan is in Boston on business and is able to attend. For more information, directions and parking please refer to the main BLU site: http://www.blu.org. -- Jerry Feldman [EMAIL PROTECTED] Boston Linux and Unix user group http://www.blu.org PGP key id:C5061EA9 PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9 signature.asc Description: PGP signature
Re: Homework problems
Jeff Kinz [EMAIL PROTECTED] writes: http://ars.userfriendly.org/cartoons/?id=19990216;-) I have that one on the cover of my Intro to Linux slides Heh, that made perfect sense to me. I almost didn't laugh :) -- Seeya, Paul ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Emacs PINE -- perfect together. [Don't hurt me!]
On Wednesday, Jan 11th 2006 at 01:30 -0500, quoth Ken D'Ambrosio: =A sad, sad truth that I've come to accept is that I have PINE's keystrokes =emblazoned in my memory. I use it at least once a year, whether I need to =or not, and I never even have to pause. They keystrokes are just THERE. =I tried MUTT. No dice. Never was a big ELM fan. And GUIs are certainly =nice, but sometimes text based is the way to fly. = =Ironically, however, I really hate PICO. = =So I've set up Emacs as my default editor. Nice. But the one problem I =have is that I'd really like to have Emacs do column-77 wordwrap if -- and =only if -- it's invoked from PINE. I have zilch idea how to invoke this =from the command line, and don't know enough about Emacs (I dabble, I don't =use) to do it any of the other ways. = =Suggestions on which approach? I've Googled, to no avail, but I know that =there are some Emacs die-hards out there, and would be glad to follow their =sagacious advice. I have this in my emacs init (add-to-list 'auto-mode-alist '(\\.txt\\'\\|^/tmp/pico . text-mode)) Combine this with using emacsclient by adding this to your init (server-start) And then just tell pine to use emacsclient. BTW, emacslient is the way to go. I have an emacs initialization that's over 200K and the machines are getting faster but on my last box with Athlon 1600's it took a couple of seconds. emacsclient is instantaneous. -- Time flies like the wind. Fruit flies like a banana. Stranger things have .0. happened but none stranger than this. Does your driver's license say Organ ..0 Donor?Black holes are where God divided by zero. Listen to me! We are all- 000 individuals! What if this weren't a hypothetical question? steveo at syslang.net ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract string
Zhao Peng [EMAIL PROTECTED] writes: First I really cannot be more grateful for the answers to my question from all of you, I appreciate your help and time. I'm especially touched by the outpouring of response on this list., which I have never experienced before anywhere else. Zhao, this is a pretty amazing list, as you and many others have discovered. It's seldom I find as good, or complete, answers anywhere else. And most often, the ensuing discussion is more interesting, educational, and enlightening than the original question posed. (It's often amusing to me when I google for an answer to a question and within the top 10 returns from google is a reference to this list. More amusing is when it was *I* who answered the question for someone else which I am now asking :) Kenny, your grep univ abc.txt | cut -f3 -d, | sed s/\//g dev.txt works. I mis-read /\ as a simliar sign on the top of 6 key on the keyboard(so when I typed that sign, I felt strange that it is much smaller than /\, but didn't realize that they just are not the same thing), instead of forward slash and back slash. I felt really embarrassed with my stupid mistake. //blush A, this makes so much more sense now. So you in fact typed something like: grep univ abc.txt | cut -f3 -d, | sed s/^/\/g ? That still doesn't end up with a '' in def.txt, but depending upon exactly what you typed, I can certainly see where the use of ^ instead of /\ could result in something like that. For educational purposes, the use of ^ is to anchor following pattern to match from the beginning of the line. Therefore: sed 's/foo/bar/g' and sed 's/^foo/bar/g' are very different, since the former results in all occurrences of 'foo' being replaced with 'bar', whereas the latter only changes foo to bar when foo is found at the beginning of the line. The use of '$' in a pattern does exactly the same thing, except for it anchors patterns at the *end* of a line. Btw, I highly recommend reading the O'Reilly book on Regular Expressions. If you're going to be doing a lot of this type of data mining, a solid understanding of regexps and mastery of perl will make your life significantly more fun. Also, you might want to play with with writing perl/shell scripts that output data parseable by gnuplot which allow you to auto-generate some rather interesting and complicated graphs of the data (I know SAS can do all this, but I bet it's no where as interesting or fun as learning the UNIX way of doing it, and you don't need an SAS license either ;) You said that there is an extra column in the 3rd line. I disagree with you from my perspective. As you can see, there are 3 commas in between jesse and Dartmouth college. For these 3 commas, again, if we think the 2nd one as an merely indication that the value for age column is missing, then the 3rd line will be be read as [jesse, MISSING, Dartmouth college], not [jesse,empty,empty, Dartmouth college] as you suggested. If you're going to be doing a lot of this type of thing, then perl will most definitely be your best friend :)a Paul, as to your simplest by what measurement question. I was thinking of both easiest to remember and easiest to understand when I was posting my question. Now I desire for most efficient approach. I know that will be my homework. Well, again, most efficient by what measurement. In the long run, I'm going to bet it's in your best interests to learn perl, since it's one tool which will allow you write rather small and arbitrarily complex scripts which would mostly obviate the need to learn several different tools like cut, sed, awk, comm, etc. In fact, learning perl will likely lead you to learn about these other tools over time as the situation dictates, but make you vastly more productive in the short term. Since perl excels at textual manipulation, it's perfect for this type of data analysis. And, since perl, combined with gnuplot, is simple to run from an Apache web server Well, I'm sure your imagination will lead you to wherever you need to go :) Good luck, and please feel free to post more interesting questions. -- Seeya, Paul ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract string
Zhao Peng writes: ... your grep univ abc.txt | cut -f3 -d, | sed s/\//g dev.txt works. It works but is it correct? What happens if you pass it the following line of input?: Aunivz,28,Cambridge Community College By your original problem description, you don't want to see Cambridge Community College but there it is. I might have overlooked something, but I believe that I have only seen two people post correct solutions so far. Just something to think about. Regards, --kevin -- (There are also also 228 babies named Unique during the 1990s alone, and 1 each of Uneekm, Uneque, and Uneqqee.) -- _Freakonomics_, Steven D. Levitt and Stephen J. Dubner [but no Unix folks named their kids uniq, apparently. --kevin] ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract string -- TIMTOWTDI
William D Ricker [EMAIL PROTECTED] writes: On 1/10/06, Paul Lussier [EMAIL PROTECTED] wrote: perl -ne 'split ,; $_ = $_[2]; s/(^)|($)//g; print if m/univ/;' abc.txt def.txt Egads! [outstanding explanation I didn't have time to write myself removed ] None of this is seriously obfuscatory golfing, but if someone wanted to say darn the cost of forking new processes off bash, 'awk/cut|grep|sed' is easier to read, well, I won't argue that it's easier for him/her to read, and they should do it that way -- unless they need to tune for performance. I would, however, offer that if someone were to find 'awk/cut|grep|sed' easier to read, then that person a) wouldn't have asked this question ;) and b) would certainly benefit from learning perl for those times when the cost of forking new processes off bash can't be ignored for some reason :) Additionally, perl offers the benefit of a debugger which can be immensely helpful for even simple one liner tasks. -- Seeya, Paul ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract string
On 1/11/06, Zhao Peng [EMAIL PROTECTED] wrote: Hi All,First I really cannot be more grateful for the answers to my questionfrom all of you, I appreciate your help and time. I'm especially touched by the outpouring of response on this list., which I have neverexperiencedbefore anywhere else. I hope my little comment didn't seem mean, I was more poking fun at the fact that if someone posted a simular post, and called themselves a Systems Administrator on a Windows network, comments simular to mine would have come forth.. ;-) Secondly I'm sorry for the big stir-up as to homework problems whichflooded the list, since I'm origin of it. Nah, it wasn't a flood. Trust me, once you see a flood, you'll know it. Usually, it's becouse someone says something political in nature. Kenny, regarding missing column issue, let me try to explain it again.Below is quoted from my original post: Also, if one column is missing, and , is used to indicate that missingcolumn, like the following (2nd column of 3rd line is missing):name,age,school jerry ,21,univ of Vermontjesse,,,Dartmouth collegejack,18,univ of Pennjohn,20,univ of south Florida ===You said that there is an extra column in the 3rd line. I disagreewith you from my perspective. As you can see, there are 3 commas inbetween jesse and Dartmouth college. For these 3 commas, again, if we think the 2nd one as an merely indication that the value for agecolumn is missing, then the 3rd line will be be read as [jesse,MISSING, Dartmouth college], not [jesse,empty,empty, Dartmouth college] as you suggested. This is unusual, as typically, a comma delimited set of values would simply have nothing between the commas, or a set of quotes with no data. Typically the line would look like this: jesse,,Dartmouth college Or jesse,,Dartmouth college Paul, as to your simplest by what measurement question. I was thinkingof both easiest to remember and easiest to understand when I was posting my question. Now I desire for most efficient approach. I knowthat will be my homework. If this is something that you will be doing repeatedly for different files types, I'd highly suggest getting familiar with regular expressions. You've seen a small snippet in Kenny's example 'sed s/\//g'. The 's/\//g' says to globally replace all quotes with nothing (s = substitute, /1/2/ says 'replace everything matching 1 with 2', in this case, a quote, with nothing. g means globally, aka, do it more then just once. Regular expressions are a powerful way to parse text files based on a given pattern, to get at the data you want. Part of my primary job responsibilities is to convert raw data into SASdata sets. My extract string question comes from processing a raw data file in .txt format, which doesn't have any documentation, except thevariable list. By looking at the raw data, I know that each variable isseparated by a comma. For one particular variable(column) calledschool, the length of some of its value is quite long(like: Univ of Wisconsin at Madison, Health Sci Ctr), but I don't know the definitelength. I need to know it, because if the length I specify it notenough, only partial values will be read. Many of its values containuniv, so I just thought if I could extract all strings containing univ from that variable(column), I will have a better chance to figureout the length of school. That's why I had this question. Haven't even run it, but something perl like: my $maxlen = 0;while() { /^(.*),(.*),(.*)$/; if(length($3) $maxlen) { $maxlen = $3; }}print Longest String in third column is $maxlen\n; This would read on STDIN till it couldn't read anymore. Each line, it would split based on the commas (If the third column contains commas, this won't work, becouse $2 or $1 would be greedy and gobble some of the data, FYI), and check the length of the third field against max length. If it's longer, assign it. At the end, print it out. This Regular _expression_ isn't great, but it's the 20 second typing version. Thomas
Re: extract string
On Jan 11, 2006, at 08:42, [EMAIL PROTECTED] wrote: This poses an interesting problem. The , is being used for two purposes: a delimiter *AND* as a place holder. I tried to prove to myself last night that this method would produce unresolvable ambiguities, but if you think like a state machine, character-by-character, it seems to work. Now, for the Lazy, Perl regular expressions are a state machine of sorts. I suspect you might be able to do the right thing with greedy/non-greedy matches. Someone who lives and breathes regex might have a better handle on this. It would take me two hours to get this one figured out. This format sure makes the parser harder though, so if there's another way to get the data that's going to be desirable. You can't use Text::CSV::Simple anymore, for instance, which gives you a 15-minute explicit reusable solution. -Bill - Bill McGonigle, Owner Work: 603.448.4440 BFC Computing, LLC Home: 603.448.1668 [EMAIL PROTECTED] Cell: 603.252.2606 http://www.bfccomputing.com/Page: 603.442.1833 Blog: http://blog.bfccomputing.com/ VCard: http://bfccomputing.com/vcard/bill.vcf ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: Homework problems
On Jan 11, 2006, at 09:26, Paul Lussier wrote: Heh, that made perfect sense to me. I almost didn't laugh :) That's because User Friendly isn't funny. (hey, Zhao hasn't seen a flamewar yet!) -Bill - Bill McGonigle, Owner Work: 603.448.4440 BFC Computing, LLC Home: 603.448.1668 [EMAIL PROTECTED] Cell: 603.252.2606 http://www.bfccomputing.com/Page: 603.442.1833 Blog: http://blog.bfccomputing.com/ VCard: http://bfccomputing.com/vcard/bill.vcf ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: extract string
On 1/11/06, Bill McGonigle [EMAIL PROTECTED] wrote: On Jan 11, 2006, at 08:42, [EMAIL PROTECTED] wrote: This poses an interesting problem. The , is being used for two purposes: a delimiter *AND* as a place holder.Now, for the Lazy, Perl regular expressions are a state machine ofsorts.I suspect you might be able to do the right thing withgreedy/non-greedy matches.Someone who lives and breathes regex might have a better handle on this.It would take me two hours to get thisone figured out. Hehe, it'd be one of those really, REALLY ugly Regular expressions that, when you stare at it long enough, looks like ASCII art in order to make it 100%. ;-) Thomas
Re: extract string
perl split on the char pair , Take last element of returned array, either remove the at the end or replace the one you ate with the split. Keep a running variable containing largest length encountered so far. Add 10 to be safe. ;-) Any regexp I have to think about for more than 30 seconds is unlikely to be used unless it greatly improves my execution speed...and then only if I have a LOT of data to process. :-) --Drew Not showing you my crufty perl VZ
Re: extract string
Zhao Peng [EMAIL PROTECTED] writes: You said that there is an extra column in the 3rd line. I disagree with you from my perspective. As you can see, there are 3 commas in between jesse and Dartmouth college. For these 3 commas, again, if we think the 2nd one as an merely indication that the value for age column is missing, then the 3rd line will be be read as [jesse, MISSING, Dartmouth college], not [jesse,empty,empty, Dartmouth college] as you suggested. From my perspective, your file format makes it harder to be parsed. If at all possible, I would suggest that if you can, you modify this file's format. Still, if this isn't possible, this works on your input: perl -lane 's/,,/,MISSING/g; @F = split /,/; if (index($F[-1], univ) != -1) { ($u = $F[-1]) =~ y///d; print $u }' Formatted more readibly, this looks like this: perl -lne 's/,,/,MISSING/g; @F = split /,/; if (index($F[-1], univ) != -1) { ($u = $F[-1]) =~ y///d; print $u }' This seems to be a reasonable solution to your problem. I hope it helps. Just another Perl hacker, --kevin -- GnuPG ID: B280F24E ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: SLUG (UNH) meeting notes for Mon 9 Jan 2006 - Plone CMS
Thanks, Ben. Work is occupying me day and night right now, so I haven't made a meeting in a while. This sounds like it was a good one! Should we be posting these notes to the wiki, preserving for posterity our impressions of events? I can see a need to try to recall some guy showed something about Plone at some meeting in the last year, and wanting to search for the information. Ted Roche Ted Roche Associates, LLC http://www.tedroche.com On Jan 10, 2006, at 9:38 PM, Ben Scott wrote: I was able to attend the SLUG meeting last night (Mon 9 Jan 2006), in Durham, at UNH. In keeping with Ted Roche's excellent work with providing notes on what happened at various meetings, I'd like to share my recollections from last night Tucker demonstrated the web linking feature. Meow. Me-ow? There was a bunch of other stuff, some of which just doesn't translate well into email, some of which I didn't understand, and some of which I just plain forgot. But it was all very cool looking. Good job, Rob! Bravo, rob! And Thanks, Ben! ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: BSD User's group?
On Jan 10, 2006, at 11:32 PM, Ben Scott wrote: I speak only for myself, but I for one would be very interested in hearing a Why I like (Free|Open|Net|*)BSD presentation from fan(s) of same. Hear, hear! I'd like to learn more. Not for debate purposes (zealots need not attend),.. Hey, we don't have any of those, do we? Martin and Jason: I also speak only for myself, but there might be sufficient interest in starting a BSD special interest group. GNHLUG and DLSLUG provides a bit of assistance to the Python SIG, mailing list, sharing announcements, etc., and a BSDish group might do the same. Rather than Balkanizing a separate group, you might want to consider riding on the coattails of the many GNHLUG meetings around the state, and meet for dinner before or after a main meeting, or arrange to do a presentation once in a while. As Ben mentioned, GNHLUG is much more about what you can do with Free Software on a computer, like Plone or Python or WebMin or LVM, an not really about Linux in an excluding sort of way. ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: SLUG (UNH) meeting notes for Mon 9 Jan 2006 - Plone CMS
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Ted Roche wrote: | Thanks, Ben. Work is occupying me day and night right now, so I | haven't made a meeting in a while. This sounds like it was a good one! Yea! I've heard that excuse before. ;-) Oops, where was I Monday night? Oh yeah. Right. I was sick. That's the ticket, I was sick! :-) | Should we be posting these notes to the wiki, preserving for | posterity our impressions of events? I can see a need to try to | recall some guy showed something about Plone at some meeting in | the last year, and wanting to search for the information. I would vote that these things go on the Wiki - unless Rob has already posted it on the slug web site (in which case we should have a pointer to it). - --Bruce -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFDxWc8/TBScWXa5IgRAoB+AKCfd/D1p51Oz14inC7KyfTW2pc06gCfYgvs +4duartgd/amTtV6qGqDu0w= =GTOE -END PGP SIGNATURE- ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss
Re: SLUG (UNH) meeting notes for Mon 9 Jan 2006 - Plone CMS
Tucker demonstrated the web linking feature. Meow. Me-ow? Reference to Tucker's demo of web-linking He found a story/picture on Yahoo of a cyclops kitten. http://slug.gnhlug.org/plone/Members/teh/cyclops-kitten/ Don't look. I warned you not to look. ___ gnhlug-discuss mailing list gnhlug-discuss@mail.gnhlug.org http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss