I am using the Powershell script to load data from about 5 Excel sheets (as a sample) from column A to AL. In reality, I have 100 Excel Sheets with 25 Tabs in each file.
I have used the link How to use powershell to copy several excel worksheets and make a new one?
And it has been of great help. However, data from the first sheet is copied and entered into the new sheet but from the 2nd File onwards it starts giving the errors as below.
The 2nd loop should go to Last Used Row of the New Excel Sheet (row 151) and paste data from the 2nd Sheet. However I run into the error "Unable to get the Select property of the Range class". Then the data from the 2nd Sheet never gets pasted.
So out of the 5 sheets data from 2 sheets gets copied while the remaining data from the other 3 sheets never gets pasted onto the new Excel Sheet mainly due to the error "Unable to get the Select property of the Range class"
Error As Received
2nd Loop
151
Unable to get the Select property of the Range class
At C:\Users\Desktop\ExcelCopy_ETC 2.ps1:84 char:51
+ ... t.Range("A$(($objDestExcel.ActiveSheet.UsedRange.Rows|Select -Last 1) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
2nd Loop
151
2nd Loop
Destination UsedRange Row: - 311
Unable to get the Select property of the Range class
At C:\Users\Desktop\ExcelCopy_ETC 2.ps1:84 char:51
+ ... t.Range("A$(($objDestExcel.ActiveSheet.UsedRange.Rows|Select -Last 1) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
2nd Loop
Destination UsedRange Row: - 311
Unable to get the Select property of the Range class
At C:\Users\Desktop\ExcelCopy_ETC 2.ps1:84 char:51
+ ... t.Range("A$(($objDestExcel.ActiveSheet.UsedRange.Rows|Select -Last 1) ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
Invalid index. (Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))
At C:\Users\Desktop\ExcelCopy_ETC 2.ps1:70 char:5
+ $SourceWorksheet = $SourceWorkBook.WorkSheets.item("3. Automation ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
2nd Loop
Destination UsedRange Row: - 311
0
Related
Here is my pyspark code used in Notebook
data_lake_container = 'abfss://abc.dfs.core.windows.net'
stage_folder = 'abc'
delta_lake_folder = 'abc'
source_folder = 'abc'
source_wildcard = 'abc.parquet'
key_column = 'Id'
key_column1 = 'LastModifiedDate'
source_path = data_lake_container + '/' + stage_folder + '/' + source_folder + '/' + source_wildcard
delta_table_path = data_lake_container + '/' + delta_lake_folder + '/' + source_folder
sdf = spark.read.format('parquet').option("recursiveFileLookup", "true").load(source_path)
if (DeltaTable.isDeltaTable(spark, delta_table_path)):
delta_table = DeltaTable.forPath(spark, delta_table_path)
delta_table.alias("existing").merge(
source=sdf.alias("updates"),
condition=("existing." + key_column + " = updates." + key_column + " and existing." + key_column1 + " = updates." + key_column1) # We look for matches on the name column
).whenMatchedUpdateAll(
).whenNotMatchedInsertAll(
).execute()
else:
sdf.write.format('delta').save(delta_table_path)
while executing above code I'm getting below error
Py4JJavaError: An error occurred while calling o771.save.
: org.apache.spark.SparkException: Job aborted.
at org.apache.spark.sql.execution.datasources.FileFormatWriter$.write(FileFormatWriter.scala:231)
at org.apache.spark.sql.delta.files.TransactionalWrite.$anonfun$writeFiles$1(TransactionalWrite.scala:216)
at org.apache.spark.sql.execution.SQLExecution$.$anonfun$withNewExecutionId$5(SQLExecution.scala:107)
Kindly help me in resolving error
Py4JJavaError: An error occurred while calling o771.save.
: org.apache.spark.SparkException: Job aborted.
The above error generally occurred because of non-compatible versions of spark connector and spark.
Refer - org.apache.spark.SparkException: Job aborted due to stage failure: Task from application
If the above solution does not work for you, please share a full stack trace of error. It is difficult to identify issues with shared information.
#AbhishekKhandave, when I looked into full error, there was date column with data range less than '1900-01-01'. That was the issue. Finally, I was able to run script. Thank you for your response.
I have installed the scala compiler and repl on my Windows 7 PC:
bitsadmin /transfer cs-cli https://git.io/coursier-cli-windows-exe "%cd%\cs.exe"
cs install scala3-compiler
cs install scala3-repl
I then copied a hello world program from this link:
https://docs.scala-lang.org/scala3/book/taste-hello-world.html
I then try to compile with scalac:
D:\projects\Coursera\scala\code\play>scalac Hello.scala
SetConsoleMode failed (is stdin a console?)
At line:29 char:10
+ throw <<<< "SetConsoleMode failed (is stdin a console?)"
+ CategoryInfo : OperationStopped: (SetConsoleMode ...din a console?):String) [], RuntimeException
+ FullyQualifiedErrorId : SetConsoleMode failed (is stdin a console?)
Hello.scala:1: error: expected start of definition
#main def hello = println("Hello, world!")
^
1 error
D:\projects\Coursera\scala\code\play>
What am I doing wrong? How can I build this program?
I am running Windows 7 Professional 64 bit.
Updated info:
D:\projects\Coursera\scala\code\play>scalac -version
SetConsoleMode failed (is stdin a console?)
At line:29 char:10
+ throw <<<< "SetConsoleMode failed (is stdin a console?)"
+ CategoryInfo : OperationStopped: (SetConsoleMode ...din a console?):String) [], RuntimeException
+ FullyQualifiedErrorId : SetConsoleMode failed (is stdin a console?)
Scala compiler version 2.13.6 -- Copyright 2002-2021, LAMP/EPFL and Lightbend, Inc.
D:\projects\Coursera\scala\code\play>scala3-compiler Hello.scala
SetConsoleMode failed (is stdin a console?)
At line:29 char:10
+ throw <<<< "SetConsoleMode failed (is stdin a console?)"
+ CategoryInfo : OperationStopped: (SetConsoleMode ...din a console?):String) [], RuntimeException
+ FullyQualifiedErrorId : SetConsoleMode failed (is stdin a console?)
D:\projects\Coursera\scala\code\play>dir
Volume in drive D is DATAPART1
Volume Serial Number is A23F-1A44
Directory of D:\projects\Coursera\scala\code\play
25/06/2021 21:55 <DIR> .
25/06/2021 21:55 <DIR> ..
25/06/2021 21:55 758 Hello$package$.class
25/06/2021 21:55 267 Hello$package.class
25/06/2021 21:55 567 Hello$package.tasty
25/06/2021 21:55 912 hello.class
25/06/2021 17:18 44 Hello.scala
25/06/2021 21:55 474 hello.tasty
6 File(s) 3,022 bytes
2 Dir(s) 522,054,057,984 bytes free
D:\projects\Coursera\scala\code\play>scala hello
SetConsoleMode failed (is stdin a console?)
At line:29 char:10
+ throw <<<< "SetConsoleMode failed (is stdin a console?)"
+ CategoryInfo : OperationStopped: (SetConsoleMode ...din a console?):String) [], RuntimeException
+ FullyQualifiedErrorId : SetConsoleMode failed (is stdin a console?)
Exception in thread "main" java.lang.NoClassDefFoundError:
scala/util/CommandLineParser$ParseError
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:398)
at scala.reflect.internal.util.RichClassLoader$.$anonfun$tryClass$extension$1(ScalaClassLoader.scala:47)
at scala.util.control.Exception$Catch.$anonfun$opt$1(Exception.scala:245)
at scala.util.control.Exception$Catch.apply(Exception.scala:227)
at scala.util.control.Exception$Catch.opt(Exception.scala:245)
at scala.reflect.internal.util.RichClassLoader$.tryClass$extension(ScalaClassLoader.scala:47)
at scala.reflect.internal.util.RichClassLoader$.run$extension(ScalaClassLoader.scala:43)
at scala.tools.nsc.CommonRunner.run(ObjectRunner.scala:30)
at scala.tools.nsc.CommonRunner.run$(ObjectRunner.scala:28)
at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:45)
at scala.tools.nsc.CommonRunner.runAndCatch(ObjectRunner.scala:37)
at scala.tools.nsc.CommonRunner.runAndCatch$(ObjectRunner.scala:36)
at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:70)
at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:91)
at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:103)
at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:108)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at coursier.bootstrap.launcher.a.a(Unknown Source)
at coursier.bootstrap.launcher.Launcher.main(Unknown Source)
Caused by: java.lang.ClassNotFoundException:
scala.util.CommandLineParser$ParseError
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:471)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
... 24 more
D:\projects\Coursera\scala\code\play>
Tried to run as scala3-compiler hello
D:\projects\Coursera\scala\code\play>scala3-compiler hello
SetConsoleMode failed (is stdin a console?)
At line:29 char:10
+ throw <<<< "SetConsoleMode failed (is stdin a console?)"
+ CategoryInfo : OperationStopped: (SetConsoleMode ...din a console?):String) [], RuntimeException
+ FullyQualifiedErrorId : SetConsoleMode failed (is stdin a console?)
not found: hello
1 error found
scala3-compiler hello.scala
scala3 Hello
or
as example from scala-lang contains annotation #main
so
def hello (hello is the class in the compiler output)
so the command to run it:
scala3 hello
The program will run nevertheless errors in cmd
Please, observe:
And here is the transcript:
PS C:\Dayforce\854\db\SQL\ClientDB> $job = Start-Job { C:\Dayforce\854\db\tools\dbupgrade\DbUpgrade.exe -d C:\Dayforce\854\db\SQL\ClientDB -db 854_dfadminportal }
PS C:\Dayforce\854\db\SQL\ClientDB> C:\Dayforce\854\db\tools\dbupgrade\DbUpgrade.exe -d C:\Dayforce\854\db\SQL\ClientDB -db 854_dfadminportal
Using timeout of 30 minutes per step.
Analyzing target DB state ...
Parsing upgrade steps ...
Found 1 new upgrade step(s). Upgrading the database ...
Dropping 2 runtime code items ...
Failed to apply DFVersion 20000
20000.sql: Divide by zero error encountered. (8134, 1)
Total Step SQL duration = 00:00:00.000
Total Step Round Trip duration = 00:00:00.035, average = 00:00:00.035
Total duration = 00:00:00.357
PS C:\Dayforce\854\db\SQL\ClientDB> Receive-Job $job.Id
Using timeout of 30 minutes per step.
Analyzing target DB state ...
Parsing upgrade steps ...
Found 1 new upgrade step(s). Upgrading the database ...
Dropping 2 runtime code items ...
Failed to apply DFVersion 20000
+ CategoryInfo : NotSpecified: (Failed to apply DFVersion 20000:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
+ PSComputerName : localhost
20000.sql: Divide by zero error encountered. (8134, 1)
Total Step SQL duration = 00:00:00.000
Total Step Round Trip duration = 00:00:00.031, average = 00:00:00.031
Total duration = 00:00:00.339
PS C:\Dayforce\854\db\SQL\ClientDB>
All I am doing is running the same executable. Once directly, once from within a background job. When receiving the output of the background job, extra error information is output. How can I get rid of it?
I am getting issue in below rule. This is working fine in 5.3 but throwing error (must be boolean expression).
String drl="import com.drools.Applicant;"
+ "rule \"Is of valid age\" "
+ " when $a : Applicant(age > 18 && name matches \"(?i).*\"+ name + \"(.|\n|\r)*\")"
+ " then $a.setValid( true ); "
+ " System.out.println(\"validation: \" + $a.isValid());\n"+
"end";
Issue is with line :
" when $a : Applicant(age > 18 && name matches \"(?i).\"+ name + \"(.|\n|\r)\")"
Any advise.
The expression isn't correct since name cannot be resolved as part of an experssion. Use a binding.
$a : Applicant($n: name, age > 18, name matches \"(?i).*\"+ $name + \"(.|\n|\r)*\")"
(I don't think the the constraint makes much sense - it's merely a test whether a name matches itself, with or without arbitrary characters before and after. Moreover, the ?i is superfluous.)
This question already has answers here:
$string.Substring Index/Length exception
(3 answers)
Closed 7 years ago.
What am I missing?
This doesn't work:
"20151129".Length
"20151129".Length - 1
"20151129".Substring(6,7)
"20151129".Substring(6,"20151129".Length -1)
But this does work:
"20151129".Substring(0,3)
Even though I'm not exceeding ("20151129".length - 1), I'm still obtaining an error:
Exception calling "Substring" with "2" argument(s): "Index and length
must refer to a location within the string. Parameter name: length" At
C:\Projects\Support\Microsoft\Powershell\DateRegex.ps1:23 char:1
+ "20151129".Substring(6,7)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentOutOfRangeException
Never mind:
"20151129".Substring(6,2)