installation errors for Perl Spreadsheet::Write - excel

I'm trying to install Spreadsheet::Write using Strawberry Perl but getting an error. Please help if you can.
perl -v reports
This is perl 5, version 32, subversion 1 (v5.32.1) built for MSWin32-x64-multi-thread
Spreadsheet::Write is failing the tests with the error message "Spreadsheet data does not match reference for 'csv'":
Running make test for AMALTSEV/Spreadsheet-Write-1.03.tar.gz
"C:\Strawberry\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t
t/all_tests.t .. ====== Expected:
Column1,Column#2,"Column 3","Column 4"
1,"Cell #2/1",C.3/1,"C.4/1/Γÿ║"
2,"Cell #2/2",C.3/2,"C.4/2/Γÿ║"
======
====== Expected:
Column1,Column#2,"Column 3","Column 4"
1,"Cell #2/1",C.3/1,"C.4/1/Γÿ║"
2,"Cell #2/2",C.3/2,"C.4/2/Γÿ║"
======
# t\tlib/Common.pm:79 - WriteCSVTest(test_text_format)
# Boolean assertion failed
# Spreadsheet data does not match reference for 'csv'
# at t\tlib/Common.pm line 79, <DATA> line 1.
# Common::spreadsheet_test(WriteCSVTest=HASH(0x2686580), "csv", GLOB(0x2692390)) called at t\tlib/WriteCSVTest.pm line 15
# WriteCSVTest::test_text_format(WriteCSVTest=HASH(0x2686580)) called at C:/Strawberry/perl/site/lib/Test/Unit/Lite.pm line 602
# eval {...} called at C:/Strawberry/perl/site/lib/Test/Unit/Lite.pm line 601
# Test::Unit::TestSuite::run(Test::Unit::TestSuite=HASH(0x2685e30), Test::Unit::Result=HASH(0x2685e60), Test::Unit::HarnessUnit=HASH(0x78a960)) called at C:/Strawberry/perl/site/lib/Test/Unit/Lite.pm line 750
# Test::Unit::TestRunner::start(Test::Unit::HarnessUnit=HASH(0x78a960), "Test::Unit::Lite::AllTests") called at t/all_tests.t line 23
t/all_tests.t .. Failed 1/3 subtests

Related

Mimicking bash wc functionalities using python

I have written a very simple python programme, called wc.py, which mimics "bash wc" behaviour to count the number of words, lines and bytes in a file. My programme is as follow:
import sys
path = sys.argv[1]
w = 0
l = 0
b = 0
for currentLine in file:
wordsInLine = currentLine.strip().split(' ')
wordsInLine = [word for word in wordsInLine if word != '']
w += len(wordsInLine)
b += len(currentLine.encode('utf-8'))
l += 1
#output
print(str(l) + ' ' + str(w) + ' ' + str(b))
In order to execute my programme you should execute the following command:
python3 wc.py [a file to read the data from]
As the result it shows
[The number of lines in the file] [The number of words in the file] [The number of bytes in the file] [the file directory path]
The files I used to test my code is as follow:
file.txt which contains the following data:
1
2
3
4
Executing "wc file.txt" returns
4 4 8
Executing "python3 wc.py file.txt" returns 4 4 8
Download "Annual enterprise survey: 2020 financial year (provisional) – CSV" from CSV file download
Executing "wc [fileName].csv" returns
37081 500273 5881081
Executing "python3 wc.py [fileName].csv" returns
37081 500273 5844000
and a [something].pdf file
Executing "wc [something].pdf" works.
Executing "python3 code.py" throws the following errors:
Traceback (most recent call last):
File "code.py", line 10, in <module>
for currentLine in file:
File "/usr/lib/python3.8/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbf in position 10: invalid start byte
As you can see, the output of python3 code.py [something].pdf and python3 code.py [something].csv is not the same as what wc returns. Could you help me to find the reason of this erroneous behaviour in my code?
Regarding the CSV file, if you look at the difference between your result and that of wc:
5881081 - 5844000 = 37081 which is exactly the number of lines.
That is, every line has one additional character in the original file. That character is the carriage return \r which got lost in Python because you iterate over lines and don't specify the linebreaks. If you want a byte-correct result, you have to first identify the type of linebreaks used in the file (and watch out for inconsistencies throughout the document).

Pyomo: sending options="threads" to cbc solver causes an error

It is possible to activate multithreading in a command line:
$cbc -threads=6
Welcome to the CBC MILP Solver
Version: 2.9.9
Build Date: Aug 21 2017
$command line - cbc -threads=6 (default strategy 1)
threads was changed from 0 to 6
But when I try to activate this option in pyomo code
opt = SolverFactory('cbc')
result = opt.solve(instance, options="threads=4")
I get an error:
File "/usr/local/lib/python3.9/dist-packages/pyomo/opt/base/solvers.py", line 561, in solve
self.options.update(kwds.pop('options', {}))
File "/usr/local/lib/python3.9/dist-packages/pyutilib/misc/misc.py", line 360, in update
if type(d[k]) is dict:
TypeError: string indices must be integers
Any ideas?
The options keyword argument expects a dictionary. If you want to use the same syntax as the command line, you're after options_string
opt.solve(instance, options_string="threads=4")
opt.solve(instance, options={"threads": 4})

Parallel programming fortran, problems with a hello program

I have problems with this basic program:
!Fortran example
program hello
implicit none
include 'mpif.h' ! If I try 'use mpi' the console don't find this module.
integer :: rank, size, ierror, tag, status(MPI_STATUS_SIZE)
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)
print*, 'node', rank, ': Hello world'
call MPI_FINALIZE(ierror)
end program hello
When I compile it, I get these errors:
$ mpirun -np 1 hello
[DESKTOP-SLDH1SC:00140] PMIX ERROR: INIT in file /pub/devel/openmpi/v4.0/openmpi-4.0.5-
1.x86_64/src/openmpi-4.0.5/opal/mca/pmix/pmix3x/pmix/src/mca/gds/ds21/gds_ds21_lock_pthread.c at line 188
[DESKTOP-SLDH1SC:00140] PMIX ERROR: SUCCESS in file /pub/devel/openmpi/v4.0/openmpi-4.0.5-
1.x86_64/src/openmpi-4.0.5/opal/mca/pmix/pmix3x/pmix/src/mca/common/dstore/dstore_base.c at line 2450
[DESKTOP-SLDH1SC:00140] PMIX ERROR: INIT in file /pub/devel/openmpi/v4.0/openmpi-4.0.5-
1.x86_64/src/openmpi-4.0.5/opal/mca/pmix/pmix3x/pmix/src/mca/gds/ds12/gds_ds12_lock_pthread.c at line 138
[DESKTOP-SLDH1SC:00140] PMIX ERROR: SUCCESS in file /pub/devel/openmpi/v4.0/openmpi-4.0.5-
1.x86_64/src/openmpi-4.0.5/opal/mca/pmix/pmix3x/pmix/src/mca/common/dstore/dstore_base.c at line 2450
[DESKTOP-SLDH1SC:00141] PMIX ERROR: ERROR in file /pub/devel/openmpi/v4.0/openmpi-4.0.5-
1.x86_64/src/openmpi-4.0.5/opal/mca/pmix/pmix3x/pmix/src/mca/gds/ds12/gds_ds12_lock_pthread.c at line 168
node 0 : Hello world
[DESKTOP-SLDH1SC:00140] [[39760,0],0] unable to open debugger attach fifo
What's wrong?
Finally, what's the difference between mpi and omp_lib?

Unable to trim the last line in the Unix file

I am trying to create and unix file with some text in it with the below command:
ssh.sendLine("echo '"+"{1:F01ZYIBGB20AXXX0000000000}{2:O5481710NDEASES0XXXX12345678901511041511180930N}\n{4:\n:16R:GENL\n:20C::SEME//"+$TradeRef+"\n:23G:INST\n:16R:LINK\n:20C::RELA//"+$TradeRef+"\n:16S:LINK\n:16R:STAT\n:25D::MTCH//MACH\n:16S:STAT\n:16S:GENL\n:16R:SETTRAN\n:35B:ISIN DE0005933931\niShares Core DAX UCITS ETF DE\n:36B::SETT//UNIT/10,\n:97A::SAFE//8696\n:22F::SETR//TRAD\n:98A::SETT//20151118\n:98A::TRAD//20151118\n:16S:SETTRAN\n-}'"+">M548File.txt");
NOw this command is createing the file M548File.txt.
When id a cat this is what i get :
{1:F01ZYIBGB20AXXX0000000000}{2:O5481710NDEASES0XXXX12345678901511041511180930N}
{4:
:16R:GENL
:20C::SEME//11111111111111111111
:23G:INST
:16R:LINK
:20C::RELA//11111111111111111111
:16S:LINK
:16R:STAT
:25D::MTCH//MACH
:16S:STAT
:16S:GENL
:16R:SETTRAN
:35B:ISIN DE0005933931
iShares Core DAX UCITS ETF DE
:36B::SETT//UNIT/10,
:97A::SAFE//8696
:22F::SETR//TRAD
:98A::SETT//20151118
:98A::TRAD//20151118
:16S:SETTRAN
-}
However when i try to open the same file in notepad i get one extraline at the last which is basically an empty line making it a total of -- 23 lines as compared to 22 in cat.
I tried the Sed commands but it just not working
Any idea how to overcome this to get 22 lines in notepad(same as cat)?

Search multiline error log for error code and then some of it's parameters on Linux

What command would give me the output I need for each instance of an error code in a very large log file? The file has records marked by a begin and end with number of characters. Such as:
SR 120
1414760452 0 1 Fri Oct 31 13:00:52 2014 2218714 4
GROVEMR2 scn
../SrxParamIF.m 284
New Exam Started
EN 120
The 5th field is the error code, 2218714 in previous example.
I thought of just grep'ing for the error code and outputting -A lines afterwards; then picking what I needed from that rather than parsing the entire file. That seems easy but my grep/awk/sed usage isn't to that level.
ONLY when error 2274021 is encountered as in the following example I'd like some output as shown.
Show me output such as: egrep ‘Coil:|Connector:|Channels faulted:| First channel:’ ERRORLOG|less
Part of input file of interest:
Mon Nov 24 13:43:37 2014 2274021 1
AWHMRGE3T NSP
SCP:RfHubCanHWO::RfBias 4101
^MException Class: Unknown Severity: Unknown
Function: RF: RF Bias
PSD: VIBRANT Coil: Breast SMI Scan: 1106/14
Coil Fault - Short Circuit
A multicoil bias fault was detected.
.
Connector: Port 1 (P1)
Channels faulted: 0x200
First channel: 10 of 32, counting from 1
Fault value: -2499 mV, Channel: 10->
Output:
Coil: Breast SMI
Connector: Port 1 (P1)
Channels faulted: 0x200
First channel: 10 of 32, counting from 1
Thanks in advance for any pointers!
Try the following (with the convenient adaptations)
#!/usr/bin/perl
use strict;
$/="\nEN "; # register separated by "\nEN "
my $error=2274021; # the error!
while(<>){ # for all registers
next unless /\b$error\b/; # ignore unless error
for my $line ( split(/\n/,$_)){
print "$line\n" if ($line =~ /Coil:|Connector:|Channels faulted:|First channel:/);
}
print "====\n"
}
Is this what you need?

Resources