Replacing a field value in one file by matching another field in another file - unix

I have a file text1 where fields are like:
box|domain|service|Consumer|organisation
Eg.for two such fields:
Datapower|utility|accountLog|verizon|google
Datapower|utility|accountLog|veri|google
Another lookup file text2 which is used for mapping is like:
Verizon|myself
What I am looking for is whenever fourth field verizon exists in text1 it should be replaced by second field myself using the mapping done in lookup file text2. But at the same time, I also need to keep in mind that if no matching is found for veri in text1 by doing lookup in text2, that row should be printed as such. Please suggest.
Thanks,
MT

The easiest way is to read first the whole files into two vectors with structure elements and then make the specified changes on it. Finally rewrite all into the same file.
The stepping file operations are hard in text files and in this case also the exchange of words would be difficult having they different lengths.

Related

Export unique JSON values from two files

I am trying to extract unique values between two JSON files. I see many jq posts on how to filter unique values within the same file, but not compare two.
Both of my files are in the same format:
{
"time":"2021-10-01T04:00:38.161Z",
"Number":2,
"signature":"e03756fa67a30d52837d3743d4d87e9a810c5e2ddf11061a976c386a742fa"
}
{
"time":"2021-10-01T04:01:38.164Z",
"Number":2,
"signature":"3b4d746ac2da2543047d8cc981db2464d4993065993449b321fc15d7f0aa6"
}
I would like to create a 3rd file which contains only unique values. If I must choose a single value to declare as unique, then I would select 'signature.'
Choose a field that will be compared (e.g. .signature) and filter by that using unique_by in the comprehensive array obtained by using the option --slurp or -s:
jq -s 'unique_by(.signature)[]' file*.txt
I'm not sure if I totally understand what you are trying to explain to us here, but if you are trying to extract/export it from your file to a command or a retrieval command, then you would need to specify which files need to be included, along with where you want to post that text to.
With any files you can extract data. For example, if you were using Sqlite:
db.fetch(`data_specified_here`)
Note: This would fetch the data from the database—or for you db file— then what you would want to do is either log or print out the data.
Since you have things like "time" and "Number"'s, you'd want to specify that that (meaning "time":2021-10-01, and so on) you need to specify that it is the string, or input you with to take out from your file.
If this didn't help, please re-ask your question with a little more detail and I can help more. I just gave a general rundown on how to fetch something from the DB, or in your case "JSON".

How write collection columns values to columns in table in word document in blueprism

I am working in blueprism and I have to loop through a collection to write back certain columns in the collection to a word file (using Business Object: MS Word VBO, and Action: Type Text). The current setup writes the collection columns values at the beginning of the word file. I would like to have those collection columns to be written in a specific table that already exists in my word template file. How can I achieve that?
Current process:
enter image description here
The current way the collection column values are written in word file:
enter image description here
I tried Set Table Cell Value and it solved my problem.

Biztalk out put Flat File has empty Records, how to avoid / remove

I am converting XML file to Flat file. I am struggling for two things.
Want to achieve tag number without mapping file tag field from source to destination. Is there any way where I can populate it if in case any value in entire row. It shouldn't display tag number if record is empty.
After i map fields, if there is no value then blank records is visible as below
101 JOB3434343 34343KKKK
301 SSSSJooojs kkkkkkkk
In the above, between 101 and 301 there is 201 which doesn't have any output value. But still the blank record is visible in output file. Please advice if anyone can.
What i am doing is as below,
there in flattening value mapping i am passing tag numbers as 101,201 and 301. however i want to see best approach.
Thank you.
For #2, Jobs_201 is probably created because there is a JOB_DETAILS record in the source that is essentially empty. You will have to link up some conditional functoids (do a Length > 0 on SLEVEL and STTYPE for instance) and link that to Jobs_201 to suppress the empty records.
Can you elaborate for #1 a bit. If you want a counter, you can use a technique similar to this: http://blogdoc.biztalk247.com/article.aspx?page=ec141ab4-78a7-4012-9273-2a50669b41e2

Comma Separated check in asp.net

How to search every word separated by comma in textbox
Please refer above post
Its Working perfectly...But i have small issues.. when i enter in text box like c,c++,4-5 yrs it have to check in database like either c,c++ skills and 4-5 yrs experiecne and then the reult has to be shown... Burt as per ur query it just show results whether any one of keyword satisfy database ...I want to compare year also how? –
If you want that behavior, you have to program that behavior. One design is to have multiple input boxes: one where you check if any of the words exist, another where you check that all of the words exist. (Perhaps even another for an exact phrase match.) Another design possibility would be for you to develop a syntax to indicate optional and required words all within a single input box. The point is it is up to you.
After you've decided on a design, then you could write code that builds your query based on or matches on the optional words and and matches on the required. Something like this pseudocode
Select * From Table Where
(Field Like OptionalWord1 Or Field Like OptionalWord2 Or Field Like OptionalWord3)
And Field Like RequiredWord1
And Field Like RequiredWord2
(etc.)

Pad Rows in BizTalk Flat File Schema

I'm trying to create a BizTalk Schema that looks something like the below (ignore the spaces between the lines- they're only there for clarity.):
"
x Rows will be inserted
Column1^Column2^Column3^Column4^Column5
Data1a^Data2a^Data3a^Data4a^Data5a
Data1b^Data2b^Data3a^Data4b^Data5b"
So, I have a blank row, followed by a Row count, followed by a header row before I get to the actual data. When I try to set up the schema so that the blank line (consists only of {CR}{LF}), and validate an instance, the schema fails (without an error message, to boot).
I'm running BizTalk 2009, and the file is a simple .txt file.
Okay... I found an answer: Feel free to chime in if you find/have a better one.
Set the blank row to a Field of Type xs:string.
Set the Header row to a single record (defining the fields all as strings).
Define the repeating record.
I'm still open to further suggestions if anyone has a better way, as this seems a little clunky to me.

Resources