I have developed a groovy application. Now it has been required
that for feeding the DB a CSV interface must be provided.
That is, I have to load a csv file, parse it and
insert records into the DB in a transactional way.
The question is if there exists for groovy something
like ostermiller utils (a configurable csv parser).
Thanks in advance,
Luis
Kelly Robinson just wrote a nice blog post about the different possibilities that are available to work with CSV files in Groovy.
Groovy and Java are interoperable. Take a look at the documentation for mixed Java and Groovy applications. Any Java class can easily be used in Groovy with no change (plus you have the groovy syntax). If you are interested in the ostermiller utils to do your CSV parsing, you can use it directly from Groovy.
If the ostermiller library does what you want you can call it directly from Groovy. Just put the necessary jars in your groovy\lib directory and you should be ready to go.
Related
Does anyone knows a good Python library to parse MSDOS files and obtain metadata and start()'s bytecodes? Like an alternative version of pefile library but for MSDOS? I can't seems to find any via Google.
If there isn't, is there a good source to refer to on MSDOS's file format? This way, I can create my own parser instead. I know there are tools like IDA Pro and Reko decompiler but I need a MSDOS file parser to automate some stuff. Thank you in advanced!
Reko decompiler maintainer here. For what it's worth, you can use Reko's MS-DOS source code and translate it to Python. It's not a lot of code and MS-DOS executables aren't that complex to parse -- it's quite a simple format. The relevant files are:
https://github.com/uxmal/reko/blob/master/src/ImageLoaders/MzExe/ExeImageLoader.cs
https://github.com/uxmal/reko/blob/master/src/ImageLoaders/MzExe/MsdosImageLoader.cs
You could also try executing the Reko code directly from Python. The Reko binaries are available as a nuget package: https://www.nuget.org/packages/Reko.Decompiler.Runtime
Use the class Reko.ImageLoaders.MzExe.ExeImageLoader in the Reko.ImageLoaders.MzExe class. Integration could be done with http://pythonnet.github.io/
I have a schema definition in a XSD file which is provided by ISO20022. This schema will need to be used in a swagger/openAPI definition (in yaml format). Since the XSD file has about 1000 lines, manual work is impracticable. This old thread mention some solution, but it is not straightforward.
Does anyone know any tool which provides an easy way to import the schema definitions from a XSD file into a swagger/openAPI yaml file?
You could try xsd2json from the npm module jgexml. It was written to do precisely this for a large API specified in XSD.
I could not escape from manual work in this task. What I've done was using "xsd2json" to convert the XSD schema to JSON. Then, I used the website www.json2yaml.com to get it as YAML. Afterwards, I created a swagger file myself, then merged the YAML file into it.
Thanks for your responses!
I'm trying to create tar.gz file using Groovy, but i couldn't find a way. Please let me know if there is any way in Groovy.
Thanks,
Srikanth.
You can use the Apache commons-compress library.
See How to Compress/Decompress tar.gz files in java
Anything that works in Java will also work in Groovy; it's just not as Groovy.
I have gone through all possible solutions online to implement data provider facility using cucumber, but all are either incomplete or not working. Can anyone please suggest a working solution to read data from an external source such as an excel or CSV? How is it used in the step defs and feature file?
Exact code might be difficult to share at the moment. But following approach should work for you. Cucumber has Interface called as Transformer which you need to implement. THe transformer implementation should be accepted as step definitions arguments. E.g.,
#Given("your text <regex>")
public void someMethod(TransformerImpl transformerImpl) {
//your code goes here
}
The TranformerImpl is the implementation of Transformer interface. In that interface you will implement the logic of taking the csv file path or name and read its content and pass its data to the step definition as argument.
Let me know if this helps.
Is there an XQuery command to load a text file?
I can load an xml document by doing the following;
declare variable $text := doc("test.xml");
But it only seems to work if test.xml is a well-formed xml document. What I want is to load a plain test.txt file into a string variable. Something like this;
declare variable $str as xs:string := fn:loadfile("test.txt");
Can it be done?
I'm using the Saxon engine but I can't find an answer in the saxon documentation.
Indeed you can find one implementation of the file functions in Zorba: http://www.zorba-xquery.com/doc/zorba-1.4.0/zorba/xqdoc/xhtml/www.zorba-xquery.com_modules_file.html
XQuery 3.0 has the function fn:unparsed-text (which was originally defined in XSLT), which does exactly what you want. XQuery 3.0 is still a work in progress though, but whilst there are not many XQuery 3.0 processors available, many XQuery processors already support this function (including Saxon).
There is a standardization effort for this on EXPath. A spec already exists for an XQuery File module that is capable of doing what you describe: EXPath File Module Spec.
Yet, I don't know how many implementations are out there. Saxon doesn't seem to implement it unfortunately (Or, please point me to it). An example implementation is shipped with zorba (see XQDoc Site of Zorba). If you want to know how to get started with zorba, you can check out this tutorial: Get Started with XQuery and Zorba.
XQuery by default( means fn: namespace ) doesn;t have any file-access methods.
MarkLogic :
xdmp:filesystem-file()
xdmp:filesystem-directory()
Zorba:
already mentioned by user457056
Exist
Exist File Module
Saxon since version 9.2 has an extension of fn:collection that can be used to read unparsed text. Here is an example:
collection('file:///c:/TEMP?select=text.txt;unparsed=yes')
This is described under "Changes in this Release" for 9.2. Apparently it is not mentioned in the function library documentation. However it works well and I have been using it a lot.