#!/usr/bin/perl # use strict; use warnings; use MongoDB; use MongoDB::OID; use Spreadsheet::ParseExcel; use Spreadsheet::XLSX; use Spreadsheet::Read; use Tie::IxHash; my $date=$ARGV[0]; $date or $date=`date --date='1 day ago' +%d-%m-%Y`; chomp $date; my $file_path="/root/prac/packages/SDP_VAS_NQI-17-06-2015.xlsx"; my $workbook = ReadData($file_path,cells => 0 ); if(defined $workbook->[0]{'error'}) { print "Error occurred while processing $file_path:".$workbook->[0] +{'error'}."\n"; exit(-1); } my $worksheet = $workbook->[1]; my $max_rows = $worksheet->{'maxrow'}; my $sqi; my $cell_data=0; for my $row_num (15..($max_rows)) { $cell_data = $worksheet->{cell}[2][$row_num]; # same, unformatted if($date eq $cell_data) { $sqi = $worksheet->{cell}[23][$row_num]; # same, unformatted print "$sqi\n"; print "$cell_data\n"; print "$row_num\n"; } } my $db_host="172.16.15.115"; my $db_name="ravi"; my $client = MongoDB::MongoClient->new(host => $db_host, port => 2 +7017); my $database = $client->get_database( $db_name ); my $data = $database->get_collection("SDP_SQI"); my %insert_data_hourly=(); $insert_data_hourly{'date'}=$cell_data; $insert_data_hourly{'SQI'}=$sqi; my $id=$data->insert(\%insert_data_hourly);

I updated as you guided. But it showing a repeated warning

 Use of uninitialized value $cell_data in string eq at ./excel_read.pl line 32.

Its nearly repeating 35 to 40 times. Whats behind in it


In reply to Re^2: Problem with inserting data into MongoDB by ravi45722
in thread Problem with inserting data into MongoDB by ravi45722

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.