Error while reading Excel file in SOAPUI using Groovy - groovy

I am trying to read an Excel file, inside SOAPUi (Free version) using Groovy.
Code :
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.xssf.usermodel.*;
import org.apache.poi.ss.util.*;
import org.apache.poi.ss.usermodel.*;
import java.io.*;
def path = "D:\\Automation\\Testdata\\testdata.xlsx"
def inputStream = new FileInputStream(path)
def wb=new XSSFWorkbook(inputStream)
def workSheet=wb.getSheet("sheet1")
def rows=workSheet.getPhysicalNumberOfRows()
long.info rows
Error :
java.lang.reflect.invocationtargetexception
I am new to SOAPUI and Groovy, but I have a decent knowledge on java. Couldnt find a proper solution for this.

Related

Import Libraries in a Python Class Package

I have created a class inside a python package. The problem is that the class uses the numpy library which is not seen when imported.
'''
import numpy as np
class NN:'''
and in the init class I wrote
'''
from net.NN import NN
'''
but when I import the package in my jupyter notebook
'''
from net import NN
'''
and I initialize the class it just gives me an error "No module named np"

ODI selective Reverse Engineering through groovy script

I try to use ODI-SDK with groovy scripting to automate selective reverse-engineering datastores to model. To do this, i used following script doStandardReverse() method, but getting error. I am trying to execute below script.
I have used API mentioned in below documentation
https://docs.oracle.com/middleware/12211/odi/reference-java-api/oracle/odi/core/service/reverse/ReverseService.html
import oracle.odi.domain.project.finder.IOdiProjectFinder
import oracle.odi.domain.model.finder.IOdiDataStoreFinder
import oracle.odi.domain.model.finder.IOdiModelFinder
import oracle.odi.domain.model.OdiModel
import oracle.odi.domain.model.OdiModelFolder
import oracle.odi.domain.model.OdiModel.ReverseObjectType
import oracle.odi.domain.project.finder.IOdiFolderFinder
import oracle.odi.domain.project.finder.IOdiUserProcedureFinder
import oracle.odi.domain.project.finder.IOdiKMFinder
import oracle.odi.domain.mapping.finder.IMappingFinder
import oracle.odi.domain.adapter.project.IKnowledgeModule.ProcessingType
import oracle.odi.domain.topology.finder.IOdiContextFinder
import oracle.odi.domain.topology.finder.IOdiLogicalSchemaFinder
import oracle.odi.domain.topology.finder.IOdiTechnologyFinder
import oracle.odi.domain.topology.OdiContext
import oracle.odi.domain.topology.OdiTechnology
import oracle.odi.domain.topology.OdiLogicalSchema
import oracle.odi.domain.model.OdiDataStore
import oracle.odi.domain.xrefs.expression.Expression
import oracle.odi.domain.xrefs.expression.Expression.SqlGroupType
import oracle.odi.domain.project.OdiProcedureLine.LogCounter
import oracle.odi.domain.project.OdiProcedureLineCmd
import oracle.odi.domain.project.OdiUserProcedure
import oracle.odi.domain.project.OdiUserProcedureLine
import oracle.odi.domain.project.OdiPackage
import oracle.odi.core.persistence.transaction.support.DefaultTransactionDefinition
import oracle.odi.core.service.reverse.ReverseService
import oracle.odi.domain.project.StepModel.ReverseModel
txnDef = new DefaultTransactionDefinition()
tm = odiInstance.getTransactionManager()
tme = odiInstance.getTransactionalEntityManager()
txnStatus = tm.getTransaction(txnDef)
def myList = ["SNP_CHECK_TAB","SRC_CITY"]
OdiModel srcModel = ((IOdiModelFinder)tme.getFinder(OdiModel.class)).findByCode("TEST_MOD");
//call reverse engeneering
rs = new ReverseService();
rm = rs.doStandardReverse(odiInstance, srcModel.getModelId(), ReverseService.DataStoreSelection.SELECTED, myList);
println('Data Store/s created.');
tm.commit(txnStatus)
I am getting error below
java.lang.String cannot be cast to oracle.odi.core.service.reverse.OdiDataStoreNameAndType
(Subtract 18 from the error line number to account for the standard imports)
java.lang.ClassCastException: java.lang.String cannot be cast to oracle.odi.core.service.reverse.OdiDataStoreNameAndType
at oracle.odi.core.service.reverse.ReverseService.convertDataStoreListToSnpsStringPair(ReverseService.java:452)
at oracle.odi.core.service.reverse.ReverseService.doStandardReverse(ReverseService.java:169)
at oracle.odi.core.service.reverse.ReverseService$doStandardReverse.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:149)
at di.run(di.groovy:61)
at groovy.lang.GroovyShell.runScriptOrMainOrTestOrRunnable(GroovyShell.java:263)
at groovy.lang.GroovyShell.run(GroovyShell.java:518)
at groovy.lang.GroovyShell.run(GroovyShell.java:497)
at groovy.lang.GroovyShell.run(GroovyShell.java:170)
at oracle.di.studio.groovy.GroovyScriptRunInstance.run(GroovyScriptRunInstance.java:222)
Script exited.
Your list contains Strings where it should contain OdiDataStore objects.
findByName method of interface IOdiDataStoreFinder can be used to find a specific OdiDataStore object.

load workbook with openpyxl ValueError Duplicate position 0.0

I'm trying to open a xlsx file in Python with openpyxl but I've this error :
raise ValueError("Duplicate position {0}".format(stop.position))
ValueError: Duplicate position 0.0
I don't understand what does it mean and I haven't found an issue explained for this error. Here is my code in file gestion_fichiers_excel :
from openpyxl import load_workbook
from openpyxl import Workbook
def loadfile():
workbook = load_workbook(filename="Feuille_decisions.xlsx")
return workbook**
def get_decisions(workbook):
num_entreprise=workbook.active["B4"].value
prix_prod1=workbook.active["B7"].value
prix_prod2=workbook.active["C7"].value
list_decisions=[num_entreprise,prix_prod1,prix_prod2]
return list_decisions
And another file which calls gestion_fichiers_excel :
import os
import tkinter as tk
import tkinter.ttk
from gestion_fichiers_excel import *
class PageDecisions(tk.Frame):
def init(self, master):
self.workbook=loadfile()
self.list_decisions=get_decisions(self.workbook)
Thanks for your help. As you can see, I'm a beginner...
I had the same issue and I found out this error was introduced in pandas version 1.2.0. Previous versions will load the file successfully.

ModuleNotFoundError using items.py

Trying to implement an Item Loader.
my class name in items.py:
SiemensLinkcontentItem
my import statements inside my spider:
import scrapy
from scrapy.loader import ItemLoader
from siemens_linkcontent.siemens_linkcontent.items import SiemensLinkcontentItem
I get the following error:
No module named 'siemens_linkcontent.siemens_linkcontent'
My path diagramm is the following:
Use This One
- from siemens_linkcontent.items import SiemensLinkcontentItem

TypeError: metaclass conflict python 3; django 2

I'm learning django 2 and have a problem.
I try to inherite some class and have this error:
"TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases"
This is my code of 'view.py':
from django.views.generic.base import TemplateView
from generic.mixins import CategoryListMixin
class MainPageView(TemplateView, CategoryListMixin):
template_name = 'mainpage.html'
But i've got this stuck only when 'CategoryListMixin' class is placed at another folder with 'view.py'. If I do like this:
from django.shortcuts import render
from django.views.generic.base import TemplateView
from django.views.generic.base import ContextMixin
class CategoryListMixin(ContextMixin):
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['current_url'] = self.request.path
return context
class MainPageView(TemplateView, CategoryListMixin):
template_name = 'mainpage.html'
Everything is okay.
Any resolving like this: Multiple inheritance metaclass conflict didn't help.
What could be a problem?
Thank you.
I found a resolving of this issue. My file and class in this file have the same name CategoryListMixin and i need to import class, but i imported file and had tried to inherite it.
Mistake was at this line:
from generic.mixins import CategoryListMixin
Right line is:
from generic.mixins.CategoryListMixin import CategoryListMixin
After that everything works correctly

Resources