How to make multiple lines become a single line in BigQuery? - replace

I have a database that has a field containing cells with multiple lines like in the picture below
Instead of separated by an 'enter'/new line, I'd like them to be combined as one line so that I can export them to CSV without any problem.
I've tried using REPLACE(rejection_reason, '\n', '') but it gives me the same output.
Is there any workaround on this?
Thank you

Hmm, REPLACE(rejection_reason, '\n', '') should work well. However, it might be related to Windows-like line separator - \r\n. I would suggest you to try:
REGEXP_REPLACE(rejection_reason, '[\n\r]', '')

Related

Replace column values using Apache NiFi

I have a sample csv looks like this
ID,FNAME,PROBLEM_COL
1,sachith,
2,nalaka,
3,john,
4,adams,
Always PROBLEM_COL value is empty. I want to replace empty with null string.
For that I used UpdateRecord processor and CSVReader with Use String Fields From Headers
Custom value as /PROBLEM_COL and ${field.value:replaceFirst('','null')}
This runs without error/warning. But PROBLEM_COL is not replaced. I had referred this, but this does not solve my issue. My headers are in block-letters.
Use replaceEmpty('null') instead of replaceFirst
https://nifi.apache.org/docs/nifi-docs/html/expression-language-guide.html#replaceempty
try to change your regex to be something like
',$'
which means: comma followed by end of line
With processor UpdateRecord you can use
replace( /PROBLEM_COL, '', 'null' )

How to exclude delimiters inside text qualifiers using Regex?

I am trying to exclude delimiters within text qualifiers. For this, I am trying to use Regex. However, I am new to Regex and am not able to fully accomplish my needs. I would be very greatful if someone can help me out.
In Alteryx, I load a delimited flat text file as 'non-delimited' and say that it does not have text qualifiers. Thus, the input will look something like this:
"aabb"|ccdd|eeff|gghh
"aa|bb"|ccdd|eeff|gghh
"aa|bb"|ccdd|"ee|ff"|gghh
"aa|bb"|"cc|dd"|"ee|ff"|"gg|hh"
"aabb"|"ccdd"|"eeff"|"gghh"
"aabb"|"ccdd"|"eeff"|"gg|hh"
aabb|ccdd|eeff|gghh
"aa|bb"|ccdd|eeff|"gg|hh"
aabb|cc|dd|eeff|gghh
aabb|"cc||dd"|eeff|gghh
aabb|"c|c|dd"|eeff|gghh
"aa||bb"|ccdd|eeff|gghh
"a|a|b|b"|ccdd|eeff|gghh
"aabb"|ccdd|eeff|"g|g|hh"
"aabb"|ccdd|eeff|"gg||hh"
I want to exclude all delimiters that are in between text qualifiers.
I have tried to use Regex to replace the delimiters within text qualifiers with nothing.
So far, I have tried the following Regex code for my target:
(")(.*?[^"])\|+(.*?)(")
And I have used the following for my replace:
$1$2$3$4
However, this will not fix te lines 11, 13, 14 and 15.
I wish to obtain the following results:
"aabb"|ccdd|eeff|gghh
"aabb"|ccdd|eeff|gghh
"aabb"|ccdd|"eeff"|gghh
"aabb"|"ccdd"|"eeff"|"gghh"
"aabb"|"ccdd"|"eeff"|"gghh"
"aabb"|"ccdd"|"eeff"|"gghh"
aabb|ccdd|eeff|gghh
"aabb"|ccdd|eeff|"gghh"
aabb|cc|dd|eeff|gghh
aabb|"ccdd"|eeff|gghh
aabb|"ccdd"|eeff|gghh
"aabb"|ccdd|eeff|gghh
"aabb"|ccdd|eeff|gghh
"aabb"|ccdd|eeff|"gghh"
"aabb"|ccdd|eeff|"gghh"
Thank you in advance for helping me out!
With kind regards,
Robin
I can't think of the correct syntax in REGEX unless you are putting in each pattern that could be found.
However, an easier way (maybe not as performant), would be to use a Text to Columns selecting Ignore delimiters in quotes. If you need it back together in one cell afterwards, you can transpose, then remove delimiters followed by a Summarize to concatenate each RecordID Group.

How to trim non-numeric characters with APEX transformation

During importing a CSV file I want to transform one column with money values so that it will insert them into database without problem.
I have values such as "134,245.99 RUB" and the output should be "134,245.99" or "134245.99" at best.
I tried doing it using transformation but there is no documentation (sic!) on that subject from Oracle how to use it.
Do you have any ideas?
#tweant: You can use regexp_replace function and do this easily. Here's an example:
select trim(regexp_replace(' 2345abc ','\D*$','')) as str from dual;
This will remove all the non digit characters from the end and trim the white spaces.
More information about the function here.

Trimming text from a multi-line entry in postgres with regex

I have a column "verbatim" where each entry contains multiple lines. Here's an example:
Dummy field1:Text
Tell Us More:Text to capture
Dummy field2:Text
I'd like to capture only Text to capture text in the second line Tell Us More: and put that value into the column verbatim_scrubbed. In the example above, Text to capture would be the entry in verbatim_scrubbed.
I'm not that great with postgres and regexp, so I was hoping somebody could help me out here. Was thinking of something similar to the following:
update TABLE
set verbatim_trimmed = array_to_string(regexp_matches(verbatim,'tell us more:(.*)','gi'));
This doesn't work, but I have a feeling something similar may work.
Perhaps there is a direct way to capture the: Text to capture without the cariage return \r and the new line \n charracters (without using the regexp_replace).
Here is what you can do:
select regexp_replace(array_to_string(regexp_matches(verbatim, '^Tell Us More:(.*)$','n'),'',''), E'[\\r\\n]', '' ) from my_table;

Coldfusion - How can I remove a '#' character from a file name

I'm running into a problem when trying to upload certain files. If a file has a '#' in the name, I get errors when trying to then open the file. Is there a way to strip the '#' character from the filename before uploading it?
I've tried using Replace, but it throws an error when I use '#' in there:
<cfset myfile = #Replace('myfile', '#', '', 'all')#>
I could use createUUID, but there may be multiple file types, so I don't necessarily know what the file extension will be.
When you upload the file, use reReplace() to remove any non alpha numeric characters in the final name of the file. You might also consider replacing spaces with underscores and/or making the name all lowercase letters.