Re: Extract same text from file.
From: Josef Moellers (josef.moellers_at_fujitsu-siemens.com)
Date: 08/16/04
- Next message: Tore Aursand: "Re: Extract same text from file."
- Previous message: Ryan Keeling: "Extract same text from file."
- In reply to: Ryan Keeling: "Extract same text from file."
- Next in thread: Tore Aursand: "Re: Extract same text from file."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 16 Aug 2004 11:52:36 +0200
Ryan Keeling wrote:
> Hi
> I have the following text file which I want to use to populate text
> files containing data only relevant to a particular project. Is it
> possible for me to group similar lines together and put them in their
> own text file? Such as a file containing all entries for
> MS102_PCP.Implementation and another file for MS102_PCP.Support.
>
> Any help would be greatly appreciated!
>
>
> 2004:01:07:3:02:MS102_PCP:Belfast:Charge:PCP:Implementation:+:5.5
> 2004:01:07:3:02:MS102_PCP:Belfast:Charge:PCP:Support:+:2.0
> 2004:01:05:1:02:MS102_PCP:Belfast:Charge:PCP:Implementation:+:7.5
> 2004:01:09:5:02:MS102_PCP:Belfast:Charge:PCP:Meetings:+:1.0
> 2004:01:20:2:04:MS102_PCP:Belfast:Charge:PCP:Standards:6.5
> 2004:01:19:1:04:MS102_PCP:Belfast:Charge:PCP:Standard:7.5
> 2004:02:03:2:06:MS102_PCP:Belfast:Charge:PCP:Support:+:2.0
> 2004:03:02:2:10:MS102_PCP:Belfast:Charge:PCP:Implementation:+:5.5
> 2004:03:03:3:10:MS102_PCP:Belfast:Charge:PCP:Implementation:+:7.5
> 2004:03:02:2:10:MS102_PCP:Belfast:Charge:PCP:Support:+:2.5
> 2004:03:26:5:13:MS102_PCP:Belfast:Charge:PCP:Support:+:7.5
> 2004:03:29:1:14:MS102_PCP:Belfast:Charge:PCP:Support:+:8.0
> 2004:03:30:2:14:MS102_PCP:Belfast:Charge:PCP:Implementation:+:8.0
> 2004:01:05:1:02:MS102_PCP:Belfast:Charge:PCP:Project-Control:+:7.5
> 2004:01:06:2:02:MS102_PCP:Belfast:Charge:PCP:Meetings:+:2.0
> 2004:01:06:2:02:MS102_PCP:Belfast:Charge:PCP:Meetings:+:0.7
Answer to your question: yes.
Obvious counter-question: what have you tried so far and where have you
had problems?
Since your data is reasonably structured, I'd use split and then create
a filename from fields 8 and 9 to append the current line to. If the
data isn't too much, you can use a hash of arrays to collect the data
and write it out in one go.
-- Josef Möllers (Pinguinpfleger bei FSC) If failure had no penalty success would not be a prize -- T. Pratchett
- Next message: Tore Aursand: "Re: Extract same text from file."
- Previous message: Ryan Keeling: "Extract same text from file."
- In reply to: Ryan Keeling: "Extract same text from file."
- Next in thread: Tore Aursand: "Re: Extract same text from file."
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|