#1
  1. cave painting, the 1st Opn Src
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2003
    Posts
    532
    Rep Power
    0

    Append to front of newline


    Code:
    ################ PATCH 4487 file activity summary ##########
    psrc/146.rpt                     6           7           Yes      Yes    
    psrc/146.scr                     12.1.6      12.1.8      Yes      Yes    
    psrc/146PD                       22.1.13     22.1.15     Yes      Yes    
    ############## PATCH 5642.42 file activity summary #######
    psrc/146.rpt                     7           8           Yes      Yes    
    psrc/146.scr                     12.1.8      12.1.9      Yes      Yes    
    psrc/146PD                       22.1.15     22.1.20     Yes      Yes    
    ############## PATCH 6412.22 file activity summary #######
    psrc/146.rpt                     8           9           Yes      Yes    
    psrc/146.scr                     12.1.9      12.2.0      Yes      Yes    
    psrc/146PD                       22.1.20     22.1.21     Yes      Yes    
    
    output desired
    6412.22,psrc/146.rpt,8,9,Yes,Yes    
    6412.22,psrc/146.scr,12.1.9,12.2.0,Yes,Yes    
    6412.22,psrc/146PD,22.1.20,22.1.21,Yes,Yes
    I need to figure out how to pull the Patch number from the first line starting with ####, and pre-pend it to the patch line, ie: prsrc/145.rpt...

    Once I do that I can strip the \t in file and get it into a prepped for insert into the table.

    How can I get achieve getting the changing patch number and add it to the patch output line?
    Curious by Nature,
    Linux by Choice
    Lawson ERP reference tools: Lawsuss.com
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2007
    Posts
    1,513
    Rep Power
    1423
    Please show your own approaches and their results first. Reading your latest posts, I get the feeling, you're just letting us do your work without any own efforts.

    Regards, Jens
  4. #3
  5. cave painting, the 1st Opn Src
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2003
    Posts
    532
    Rep Power
    0
    I think that is a little unfair that you want to decide whether or not this forum should help me because you think I am asking to many questions or the wrong type of request.
    I've posted a few questions in the last week while working thru some new code ideas and asking for syntax help.

    I try to post sample snippets, current results and desired results. If I post a portion of the problem, you don't see the other 70-80% of the problem that I've already fixed. And, 95% of the time I've already Google'd or visited php.net to look for an answer.

    If you look at this question I don't ask a multiple part questions, I ask for help trying to tackle the first step in this process. That is not asking you do to my work, I'm asking someone for possible ways to solve this problem. If you can help, then please post an answer or post a link because I have no idea how to pull a piece of a string out of a file and pre-append it to the next line in the file.

    And note, the detail of this post is the overall outcome, I in NO WAY asked for a complete answer, I asked
    how to pull the Patch number from the first line starting with ####, and pre-pend it to the patch line
    . That is 1 request for help. And I noted
    Once I do that I can strip the \t in file and get it into a prepped for insert into the table.
    , the follow on steps that I had in mind for this question.

    Answer if you want, Plonk if you want, but unless you have the authority to ban me for asking for help I'm going to ask you to keep your comments to yourself.

    Thanks!
    Curious by Nature,
    Linux by Choice
    Lawson ERP reference tools: Lawsuss.com
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Jun 2007
    Posts
    1,513
    Rep Power
    1423
    Originally Posted by dba_frog
    Answer if you want, Plonk if you want, but unless you have the authority to ban me for asking for help I'm going to ask you to keep your comments to yourself
    Sorry, but that's a luxury you don't get after continuously ignoring the "How to ask smart questions" guide. You've reached a point, where I'm seriously doubting, I really want to answer your question, since I'm getting the expression, you don't learn from previous answers. The reason why I get this impression is, because you're repeatedly asking very very basic questions without any obvious effort on your part.

    That said, let me give you some pointers in the right direction, afterwards the rest is up to you:

    - You'll need to deal with your input line by line.
    - You'll have to decide what to do, depending on the beginning of your line.
    - You're looking for an algorithm, not for a regular expression, since a single regular expression cannot solve your problem.
    - Whenever you encounter a new patch set information, store the version info somewhere.
    - Whenever you encounter a new file, use its data together with the stored information from the new patch set header.
    - Forget the thing with stripping the tabs. Use them as a delimiter, when parsing your file info line.

    Regards, Jens
  8. #5
  9. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,692
    Rep Power
    6351
    You've dealt with loops and arrays in PHP before, as I can see from the various arguments you've had on the topic with our long-standing members.

    Jens' advice is correct. Loop line by line. If the line starts with ###, replace the stored prepend number. If not, re-format the line with the prepend number.

    The new user guide (which contains information on asking good questions and proper forum etiquette) is right below this message. Yes, you've been on the forums for a while, but you're very combative and this question was pretty much "this is what I start with, this is how I want it to end up, please help." YOU may understand that this is a small set of an overall problem and you're only giving us 10% of it, but we don't. Your answer is "this is not a regular expression question, this is a file parsing question, parse it line by line."

    Which language are you familiar with? You've posted in both Perl and PHP. I will move this thread to the appropriate forum for you based on how you'd like to solve it.

    -Dan
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.

IMN logo majestic logo threadwatch logo seochat tools logo