XQUERY - how to get xml filename - xquery

I have a xml file $doc, I want to retrieve its file name so I use base-uri($doc) or document-uri($doc) with this result: "file:/C:/Users/Desktop/corpus/Decree.xml".
How can I get just "Decree.xml"?

Use tokenize and select the last token e.g. tokenize(base-uri($doc), '/')[last()].

Related

How to add space in Txt file using robotframework

${response14} Get WebElements xpath=// [#id="com_ibm_team_rtc_foundation_web_ui_views_ArtifactListView_4"]
Log ${response14}
${txt1}= Get Text ${response14}
create file ${file2} ${value_1}${txt}${value_11}${txt1}
Log ${txt1}
Here I want to store the value of ${value_1}${txt}${value_11}${txt1} in different lines in text file.
I am able to store all the values in a paragraph, but i don't want that, i need to store in different lines, How do I do this in robot framework
You can insert newlines using \n:
create file ${file2} ${value_1}\n${txt}\n${value_11}\n${txt1}
${CreatingFile} = Create File ${EXECDIR}/data/file.txt
Log to Console

Copy dictionary to register in Vim

I have a dictionary in my vimrc that I would like to copy and paste into whatever text file I'm editing:
let info = { 'tom':12345, 'bob':54689 }
I tried using put as I would with an option setting but I get an error:
:put=#info
How do I copy the contents of "info" to the register so that I can paste it in my text document?
If you want to maintain the exact representation, you have to store the dictionary as a string already (as per #sergio's answer), and you can :put it directly.
If it's fine to have Vim render the dictionary (and potentially reorder its elements), you just have to explicitly convert to a string, in order to overcome the E731: using Dictionary as a String (as it's :help explains, these types are not automatically converted). The string() function will do that:
:put =string(info)
Try quoting the json data. And removing # from put command (# is used to accessed registers, not for variables):
:let info="{ 'tom':12345, 'bob':54689 }"
:put=info

U-SQL get filename of input and use for output

I have a filename of test.csv and I want the output to be test.txt.
I can extract the filename of the input but don't know how to use it for the output?
OUTPUT #result TO "/output/{filename}.txt"
USING Outputters.Text(outputHeader:false, quoting:false);
The filename is in the #result.
This feature isn't supported as of yet.
Does anyone have a work around?
U-SQL How can I get the current filename being processed to add to my extract output?
Ideally I would like dd-mm-yy-test.text?
How do I append the day month and year?
I am using USQL for this.
Thanks
Let me address both issues you're laying out in this question:
To use the same output name as the input, there would have to be a way to access rowset values into u-sql variables which I'm pretty sure cannot be done, taking into account that the language is built around the necessity to process many files at once.
To append a date into the output you would only need to declare the current datetime at some point and then use it to write the output file name like this:
DECLARE #now DateTime = DateTime.Now;
OUTPUT #output TO "/tests/output/" + #now.ToString("dd-MM-yyyy") + "-output.csv" USING Outputters.Csv();

U-SQL How can I get the current filename being processed to add to my extract output?

I need to add meta data about the Row being processed. I need the filename to be added as a column. I looked at the ambulance demos in the Git repo, but can't figure out how to implement this.
You use a feature of U-SQL called 'file sets' and 'virtual columns'. In my simple example, I have two files in my input directory, I use file sets and refer to the virtual columns in the EXTRACT statement, eg
// Filesets, file set with virtual column
#q =
EXTRACT rowId int,
filename string,
extension string
FROM "/input/filesets example/{filename}.{extension}"
USING Extractors.Tsv();
#output =
SELECT filename,
extension,
COUNT( * ) AS records
FROM #q
GROUP BY filename,
extension;
OUTPUT #output TO "/output/output.csv"
USING Outputters.Csv();
My results:
Read more about both features here:
https://msdn.microsoft.com/en-us/library/azure/mt621320.aspx

SQLite: How to select only the filename without extension?

I need to extract the filename without the extension from one of tables I have.
Currently I have used
SELECT filename FROM files
is used which returns the entire filename (Jessica.Timber.mp3). So is it possible to get only the filename using sqlite(eg: Jessica.Timber )? The files may contain multiple "." but only the last dot followed by the the ext should be removed.
I tried the following query, which provides the result if the extension is only 3 letter long (eg: *.mp3) but fails if its more than that (eg: *.flac)
SELECT substr(filename, -4, -100) from files;
Below is the query - will get you the file name without extension irrespective of extension length. File name can contain any number of . character (Tested and verified)
select replace(filename
, '.' || replace(filename
, rtrim(filename, replace(filename, '.', '') )
, '')
, '')
from files;
Test:
create table files (filename);
insert into files values ("ph.otoJpg.jpg"), ("ph.otoJpeg.jpeg");
Then the above code yields:
ph.otoJpg.
ph.otoJpeg.
SQLite has no built-in string functions that would help with this.
It would be possible to create a recursive CTE, but the easiest way is to retrieve the entire file name and to remove the extension in your code.

Resources