How to parse out specific data in text files and plugs into the

How to parse out specific data in text files and plugs into the

am 06.12.2007 23:40:31 von cyrusgreats

I need help writing a script in perl that takes text files and parses
out specific data and plugs the data back into the spreadsheet. Can
anyone help me on that..Thanks in advance..

Re: How to parse out specific data in text files and plugs into the spreadsheet

am 07.12.2007 00:20:06 von glex_no-spam

cyrusgreats@gmail.com wrote:
> I need help writing a script in perl that takes text files and parses
> out specific data and plugs the data back into the spreadsheet. Can
> anyone help me on that..Thanks in advance..

The documentation can help, along with thousands of Web sites, and
many, many books.

perldoc perlopentut
perldoc -f split

Books:

http://books.perl.org/

Re: How to parse out specific data in text files and plugs into the spreadsheet

am 07.12.2007 02:38:48 von Tad McClellan

cyrusgreats@gmail.com wrote:
> I need help writing a script in perl that takes text files and parses
> out specific


You have left the specifics unspecified...


> data and plugs the data back into the spreadsheet.


Errr, what flavor of spreadsheet would that be?

Many of them have there own, uncompatible, data formats.


> Can
> anyone help me on that..


Yes.


> Thanks in advance..


You're welcome in advance.


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Re: How to parse out specific data in text files and plugs into the

am 07.12.2007 17:28:23 von cyrusgreats

On Dec 6, 5:38 pm, Tad McClellan wrote:
> cyrusgre...@gmail.com wrote:
> > I need help writing a script in perl that takes text files and parses
> > out specific
>
> You have left the specifics unspecified...
>
> > data and plugs the data back into the spreadsheet.
>
> Errr, what flavor of spreadsheet would that be?
>
> Many of them have there own, uncompatible, data formats.
>
> > Can
> > anyone help me on that..
>
> Yes.
>
> > Thanks in advance..
>
> You're welcome in advance.
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"

Well what meant by specifics, each person in this exmaple have an id
as follows:

Capitan id : 123456
Time arrival : 10:00:56
Time left : 12:11:23

Capitan id : 88456
Time arrival : 1100:56
Time left : 12:17:0

As for spreadsheet, excel file would work!

Re: How to parse out specific data in text files and plugs into the spreadsheet

am 07.12.2007 17:42:53 von glex_no-spam

cyrusgreats@gmail.com wrote:

>>> I need help writing a script in perl that takes text files and parses
>>> out specific
[...]
> Well what meant by specifics, each person in this exmaple have an id
> as follows:
>
> Capitan id : 123456
> Time arrival : 10:00:56
> Time left : 12:11:23
>
> Capitan id : 88456
> Time arrival : 1100:56
> Time left : 12:17:0
>
> As for spreadsheet, excel file would work!

You will need to put SOME work into this. You'll have to
parse it into the various fields and you could use
Spreadsheet::WriteExcel to create an Excel file.

http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.2 0/lib/Spreadsheet/WriteExcel.pm

Re: How to parse out specific data in text files and plugs into the

am 07.12.2007 18:18:35 von cyrusgreats

On Dec 7, 8:42 am, "J. Gleixner"
wrote:
> cyrusgre...@gmail.com wrote:
> >>> I need help writing a script in perl that takes text files and parses
> >>> out specific
> [...]
> > Well what meant by specifics, each person in this exmaple have an id
> > as follows:
>
> > Capitan id : 123456
> > Time arrival : 10:00:56
> > Time left : 12:11:23
>
> > Capitan id : 88456
> > Time arrival : 1100:56
> > Time left : 12:17:0
>
> > As for spreadsheet, excel file would work!
>
> You will need to put SOME work into this. You'll have to
> parse it into the various fields and you could use
> Spreadsheet::WriteExcel to create an Excel file.
>
> http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.2 0/lib/Spr...- Hide quoted text -
>
> - Show quoted text

I've already wrote the code for Spreadsheet what is left parsing the
data and put them possibly into the has with their value.

Re: How to parse out specific data in text files and plugs into the spreadsheet

am 07.12.2007 18:47:21 von glex_no-spam

cyrusgreats@gmail.com wrote:
> On Dec 7, 8:42 am, "J. Gleixner"
> wrote:
>> cyrusgre...@gmail.com wrote:
>>>>> I need help writing a script in perl that takes text files and parses
>>>>> out specific
>> [...]
>>> Well what meant by specifics, each person in this exmaple have an id
>>> as follows:
>>> Capitan id : 123456
>>> Time arrival : 10:00:56
>>> Time left : 12:11:23
>>> Capitan id : 88456
>>> Time arrival : 1100:56
>>> Time left : 12:17:0
>>> As for spreadsheet, excel file would work!
>> You will need to put SOME work into this. You'll have to
>> parse it into the various fields and you could use
>> Spreadsheet::WriteExcel to create an Excel file.
>>
>> http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.2 0/lib/Spr...

> I've already wrote the code for Spreadsheet what is left parsing the
> data and put them possibly into the has with their value.

You could use split or a regular expression.

perldoc -f split
perldoc perlretut

Why not give it a try, post it, and explain what steps are
causing problems. You're not paying us enough to write your
code for you. :-)

Re: How to parse out specific data in text files and plugs into the

am 07.12.2007 18:49:34 von Ben Morrow

[please don't quote Google's -hide quoted text- rubbish]

Quoth cyrusgreats@gmail.com:
> On Dec 7, 8:42 am, "J. Gleixner"
> wrote:
> > cyrusgre...@gmail.com wrote:
> > >>> I need help writing a script in perl that takes text files and parses
> > >>> out specific
> > [...]
> > > Well what meant by specifics, each person in this exmaple have an id
> > > as follows:
> >
> > > Capitan id : 123456
> > > Time arrival : 10:00:56
> > > Time left : 12:11:23
> >
> > > Capitan id : 88456
> > > Time arrival : 1100:56
> > > Time left : 12:17:0
> >
> > > As for spreadsheet, excel file would work!
> >
> > You will need to put SOME work into this. You'll have to
> > parse it into the various fields and you could use
> > Spreadsheet::WriteExcel to create an Excel file.
> >
> >
> http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.2 0/lib/Spr...-
>
> I've already wrote the code for Spreadsheet what is left parsing the
> data and put them possibly into the has with their value.

You mean like

my @records;

{
open my $FILE, '<', 'file.txt'
or die "can't open file.txt: $!";

local $/ = '';

while (my $rec = <$FILE>) {
my @fields = split /\n/, $rec;
my %rec;

for (@fields) {
my ($k, $v) = /([^:]*) \s* : \s* (.*)/x
or die "invalid field: '$_'";
$rec{$k} = $v;
}

push @records, \%rec;
}
}

? Was that really so difficult?

Ben

Re: How to parse out specific data in text files and plugs into the

am 07.12.2007 21:52:56 von cyrusgreats

On Dec 7, 9:49 am, Ben Morrow wrote:
> [please don't quote Google's -hide quoted text- rubbish]
>
> Quoth cyrusgre...@gmail.com:
>
>
>
>
>
> > On Dec 7, 8:42 am, "J. Gleixner"
> > wrote:
> > > cyrusgre...@gmail.com wrote:
> > > >>> I need help writing a script in perl that takes text files and parses
> > > >>> out specific
> > > [...]
> > > > Well what meant by specifics, each person in this exmaple have an id
> > > > as follows:
>
> > > > Capitan id : 123456
> > > > Time arrival : 10:00:56
> > > > Time left : 12:11:23
>
> > > > Capitan id : 88456
> > > > Time arrival : 1100:56
> > > > Time left : 12:17:0
>
> > > > As for spreadsheet, excel file would work!
>
> > > You will need to put SOME work into this. You'll have to
> > > parse it into the various fields and you could use
> > > Spreadsheet::WriteExcel to create an Excel file.
>
> >http://search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2. 20/lib/Spr...
>
> > I've already wrote the code for Spreadsheet what is left parsing the
> > data and put them possibly into the has with their value.
>
> You mean like
>
> my @records;
>
> {
> open my $FILE, '<', 'file.txt'
> or die "can't open file.txt: $!";
>
> local $/ = '';
>
> while (my $rec = <$FILE>) {
> my @fields = split /\n/, $rec;
> my %rec;
>
> for (@fields) {
> my ($k, $v) = /([^:]*) \s* : \s* (.*)/x
> or die "invalid field: '$_'";
> $rec{$k} = $v;
> }
>
> push @records, \%rec;
> }
> }
>
> ? Was that really so difficult?
>
> Ben- Hide quoted text -
>
> - Show quoted text -

Thanks but I'm getting error: invalid field in this line:
my ($k, $v) = /([^:]*) \s* : \s* (.*)/x
or die "invalid field: '$_'";