Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Perl Reading Excel sheet isssue


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Perl Reading Excel sheet isssue

There is a perl scriptwhich will read Excel sheet and create one file(.v) .

Code:
Excel sheet::: 
     A              B   C   D
1  cpu_dailog   2   3   4



Perl will create the file(.v) like thsi :::

Code:
assert (cpu_dailog_iso ==2) ; 
assert (cpu_dailog_reset ==3);
assert (cpu_dailog_idle ==4);

My Requirement:::
If Row1+ColumnC (Value is 3 there) is having coloured background "Blue" , then i want to add comment . like this in generated file


Code:
assert (cpu_dailog_iso ==2) ; 
//assert (cpu_dailog_reset ==3);
assert (cpu_dailog_idle ==4);

Plz guys can any body help?
There are lot of signals. Its very pain to do it manually .

Quote:
//------------------------------------------Some part of the script---------------------------//
foreach $out_port (keys (%{$design{$ip_name}{output}})) {
if ($design{$ip_name}{output}{$out_port}{"reset_sig"} eq $reset_var) {
if (defined ($design{$ip_name}{output}{$out_port}{"single"})) {
print OUTPUT_FILE (" $ip_name\_level1_PRM_$out_port\_reset : assert \($out_port === 1\'h$design{$ip_name}{output}{$out_port}{\"reset_val\"}\)",
" else if\(assert_check_reset\) \$error\(\"$ip_name\_level1_PRM_$out_port\_reset_Assertion: incorrect reset value for $out_port +++ Xcel Value = 1\'h$design{$ip_name}{output}{$out_port}{\"reset_val\"} +++ RTL Value = %h\" ,$out_port \)\;\n");
} else {
$out_port_width = (($design{$ip_name}{output}{$out_port}{"bus_high"} - $design{$ip_name}{output}{$out_port}{"bus_low"}) + 1);
print OUTPUT_FILE (" $ip_name\_level1_PRM_$out_port\_reset : assert \($out_port === $out_port_width\'h$design{$ip_name}{output}{$out_port}{\"reset_val\"}\)",
" else if\(assert_check_reset\) \$error\(\"$ip_name\_level1_PRM_$out_port\_reset_Assertion: incorrect reset value for $out_port +++ Xcel Value = $out_port_width\'h$design{$ip_name}{output}{$out_port}{\"reset_val\"} +++ RTL Value = %h\" ,$out_port \)\;\n");
};
}
};

Last edited by naaj_ila; 10-30-2012 at 11:26 AM..
# 2  
Well, it might be easier to use Excel or LibreOffice to globally replace the blue background with a nice selective key prefix in the cell, and save it as tab separated text. Is this one of several xls format or xlsx ?
# 3  
My sample Excel spreadsheet, called "test_file.xlsx" looks like this -

Code:
  | A             | B   |   C   |   D   |
--+---------------+-----+-------+-------+
1 | cpu_dialog    | 2   |   3   |   4   |
--+---------------+-----+-------+-------+
2 | something_else| 20  |   30  |   40  |
--+---------------+-----+-------+-------+

and the background color of Cell C1 is blue.

Here's some Perl code:

Code:
c:\>
c:\>
c:\>REM Display the Perl program to process MS Excel workbook "test_file.xlsx"

c:\>
c:\>type read_excel.pl
#!perl -w
use strict;
use Win32::OLE;

$Win32::OLE::Warn = 3;              # die on errors
my $excelfile = 'test_file.xlsx';   # file to be read

my $Excel = Win32::OLE->GetActiveObject('Excel.Application')
            || Win32::OLE->new('Excel.Application', 'Quit');

my $Book = $Excel->Workbooks->Open($excelfile);
my $Sheet = $Book->Worksheets("Sheet1");

my $comment = "";
my @row_values;
my %suffix = qw (1 _iso 2 _reset 3 _idle);
foreach my $row (1..2) {
  foreach my $col ("a".."d") {
    my $range = $col.$row;
    push @row_values, $Sheet->Range($range)->{Value};
    if ($range eq "c1" and $Sheet->Range($range)->Interior->{ColorIndex} == 23) { # ColorIndex = 23 for Blue
      $comment = "//";
    }
  }
  foreach my $i (1..3) {
    printf ("%sassert (%s%s == %s);\n", $row==1 && $i==2 ? $comment : "", $row_values[0], $suffix{$i}, $row_values[$i]);
  }
  @row_values = ();
}

c:\>
c:\>
c:\>
c:\>REM Now run the Perl program

c:\>
c:\>perl read_excel.pl
assert (cpu_dialog_iso == 2);
//assert (cpu_dialog_reset == 3);
assert (cpu_dialog_idle == 4);
assert (something_else_iso == 20);
assert (something_else_reset == 30);
assert (something_else_idle == 40);

c:\>
c:\>
c:\>

tyler_durden
This User Gave Thanks to durden_tyler For This Post:
# 4  
OK, xlsx,very interesting, a zip file full of xml files. I suppose the right late model perl classes can make it simple, but maybe not that simple. It looks like color can be by index or rgb.

Have it print state change and value discovery messages as it goes. Did it find the cell, find the color, and what colors did it find?
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Perl : to get all the hyperlinks from the xlsx sheet(hyperlinks not visible in excel sheet directly)
scriptscript
Hi folks, I have a requirement in perl to print all the hyperlink from the spreadsheet(xlsx). Spreadsheet contains few lines of hyperlink data (pic attached). P.S. Hyperlink is behind the data and not visible in excel sheet directly. Now using perl script I need to copy the hyperlinks in...... Shell Programming and Scripting
3
Shell Programming and Scripting
Perl : not capturing all the data from excel sheet
giridhar276
Hi folks, I am working on assignment that captures all the records(2 columns one column contains names and other contain date of birth) from excel sheet stored in a directory and checks for current date and month. If it matches current date and month then the matched records are printed as...... Shell Programming and Scripting
1
Shell Programming and Scripting
Excel sheet modification using perl module
kavi.mogu
Hi , Is there any possibility to read excel sheet in column by column order ?...Thanks in advance,........ :confused:... Shell Programming and Scripting
1
Shell Programming and Scripting
Excel sheet modification using perl module
kavi.mogu
I need to insert new column to already existing file ..can any one help me..??... Shell Programming and Scripting
6
Shell Programming and Scripting
Excel sheet modification using perl module
kavi.mogu
Is there any possibility to move the content from one cell to another cell (Excel sheet) using perl module?... Shell Programming and Scripting
3
Shell Programming and Scripting

Featured Tech Videos