On 8/28/07, oryann9 <[EMAIL PROTECTED]> wrote:
snip
> Thank you for replying but since I am trying to learn
> your response did not help much. :(
> Any add'l help?
snip
#!/usr/bin/perl
use strict;
use warnings;
use DBI;
my $dbh = DBI->connect(
'DBI:CSV:f_dir=csvdb', #the directory csvdb
--- Lawrence Statton <[EMAIL PROTECTED]> wrote:
> > I read the CPAN module DBD::CSV and still had some
> > questions.
> >
> > 1)Does this create a "in memory" database with
> data
> > from the spreadsheet for manipulation?
>
> What did reading the source tell you?
>
> >
> > 2)This is really c
> I read the CPAN module DBD::CSV and still had some
> questions.
>
> 1)Does this create a "in memory" database with data
> from the spreadsheet for manipulation?
What did reading the source tell you?
>
> 2)This is really cool! Does anyone have a working
> example of inserting, deleting and sub
> Something like
> #!/usr/bin/perl
> use strict;
> use DBI;
>
> my $dbh =
> DBI->connect("DBI:CSV:f_dir=/dir/with/the/csvs")
> or die "Cannot connect: " . $DBI::errstr;
>
> $dbh->{'csv_tables'}->{'SomeName'} = { 'file' =>
> 'SomeName20070827.csv'};
> # tie the table name to the filenam
From: "Mihir Kamdar" <[EMAIL PROTECTED]>
> I have a csv file. I wanted to do some calculations on some of its fields,
> like multiplying the 7th field with the 13th field and overwriting the 13th
> field with the answer of my calculation.
>
> Regarding this, can I do the calculations on the input
2007/8/24, Mihir Kamdar <[EMAIL PROTECTED]>:
>
> Here if I want the $cdr[13] to be written as a float(ex. 15.00), then how do
> I write it?
>
$cdr[13] = sprintf "%.2f", $cdr[6]*5.0 ;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl
Perl isn't a strong type language,it doesn't mind which data type it used.
> You can use printf() for printing a floating vlaue,like,
> $ perl -e 'printf("%.2f",3)'
> 3.00
that's right, but with respect to this particular code of mine, the $cdr[13]
is the "amount" field which should be a float.
2007/8/24, Mihir Kamdar <[EMAIL PROTECTED]>:
> But a few improvizations. $cdr[13] that I am trying to manipulate is a
> "amount" field and should be a floating point value...how can I print it as
> floating point in perl?
>
Perl isn't a strong type language,it doesn't mind which data type it used
Hi,
Thanks...i got my mistake...it worked after the below as Rob suggested:-
my @cdr=split (/,/, $line) ;
$cdr[13] = $cdr[6]*5.0 ;
$line = join(",",@cdr);
$hash{"@cdr[2,3,6,7]"}=$line;
But a few im
2007/8/24, Mihir Kamdar <[EMAIL PROTECTED]>:
> $cdr[13] = $cdr[6]*5 ;
> $hash{"@cdr[2,3,6,7]"}=$line;
Hello,
I checked the codes,but I'm not sure what's the meanings of those 2 lines above.
I can't see the logic relation with the 2 l
Of course it is
Your %hash gets filled with a structure that looks like this:
{ KEY => VALUE }
{ "@cdr[2,3,6,7]"=> $line}
Then you take all the values and write them out to a file. Since you never
changed the $line variable you should get the same result in your out file
as
On 8/24/07, Jeff Pang <[EMAIL PROTECTED]> wrote:
>
> 2007/8/24, Mihir Kamdar <[EMAIL PROTECTED]>:
>
> > $cdr[13] = $cdr[6]*5 ; ###Can I do something like this
>
> sure,why can't?
Hi,
Please look at my code below and comment. I am trying to manipulate 13th
field of my record. But I am not
Your idea should work pretty well assuming that you are 100% sure that the
thing in field 7 really is a number, you might get strange results if field
7 is empty or somehting else then a number.
As for how to handle the files that is really up to you and the environment
you work in... if your file
2007/8/24, Mihir Kamdar <[EMAIL PROTECTED]>:
> $cdr[13] = $cdr[6]*5 ; ###Can I do something like this
sure,why can't?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/
Hi,
I have a csv file. I wanted to do some calculations on some of its fields,
like multiplying the 7th field with the 13th field and overwriting the 13th
field with the answer of my calculation.
Regarding this, can I do the calculations on the input file and overwrite it
after calculating, or I
15 matches
Mail list logo