Encoded values to plain text in Redshift - amazon-web-services

I have encoded values in the table, and wanted to select them as a plain text without altering the database property,
I have tried many ways, but not getting exact result.
Value - Er tręäńgt keinen Manteł Expected - Er treangt keinen Mantel
SELECT 'Er tręäńgt keinen Manteł', 'Er tręäńgt keinen Manteł'::bytea;
SELECT 'Er tręäńgt keinen Manteł', convert_to('Er tręäńgt keinen Manteł', 'utf-8');
Any suggestion will be helpful.

Related

Need to extract information from PDF using Regular expression

I need to extract information for two word tags from a list of pdfs using regular expression.
The structure of every pdf would be same. I can read the whole text of pdf using UiPath activity but I need to extract only some information from that whole text using regex.
The first word tag is Wertmindernde Faktoren (in bold) and it will always have information like below (in table manner)
Please click on the link to see the image
As you can see the information is in table format and I need to use regex to extract in table format only for this particular tag.
The second tag is Gebrauchsspuren (in bold)
This will have information sometimes in table format or sometimes in a sentence.
Mentioned below
Table Format
Sentence Format
So any help or suggestion on what will be the regex for these two tags ?
Thanks in advance.
Please find the sample below, I need to extract the table under the word "Wertmindernde Faktoren"
Vordersitze beheizbar
Vordersitze elektrisch einstellbar, Fahrersitz mit Memory, Komforteinstieg, längs verschiebbarer
Oberschenkelauflage
Wegfahrsperre elektronisch
20.07.2021 Gutachtennummer: XXXXXXX Seite 6 / 17TÜV SÜD Auto Plus GmbH Fahrzeugbewertung
Wiesenring 2
04159 Leipzig
+XXXXXXXXXXXX
GUTACHTENNUMMER: XXXXXX
Bei Rückfragen bitte Gutachtennummer und Datum angeben Datum: 20.07.2021
Ausstattung
Zentralverriegelung ohne Safe-Sicherung,mit Funkfernbedienung, 2 Funkschlüssel, Komfortstartfunktion
"Press & Drive"
Wertmindernde Faktoren
Nr. Bauteilgruppe Beschreibung
1 Heckklappe/-tür Heckklappe - Dellen - sanft instandsetzen
Gebrauchsspuren
Nr. Bauteilgruppe Beschreibung
1 Stossfänger vorn Spoiler (Unterhalb) - Kratzer - kein Abzug
2 Stossfänger hinten Stossfänger hinten - Kratzer - kein Abzug
3 Tür hinten rechts Tür - Dellen - kein Abzug
4 Tür vorn rechts Tür - Dellen - kein Abzug
Vorschaden
Nr. Vorschaden Schadenshöhe
1 fachgerecht repariert , Reparaturrechnung nicht vorhanden 311,10 €
2 fachgerecht repariert , Reparaturrechnung nicht vorhanden 493,31 €
3 Seite links, fachgerecht repariert , Reparaturrechnung nicht vorhanden
Summe (netto): 804,41 €
Nachlackierungen
Nr. Ort
1 Tür vorne links, fachgerecht ausgeführt
Hinweise zum Gutachten
Angaben zum Auftrag und zum Begutachtungsumfang:
Es wurde der Auftrag erteilt, eine Fahrzeugbewertung über das beschriebene Fahrzeug zu erstellen.
Try this regex :
(?:Wertmindernde Faktoren.*)\n(.*(?:\n.+)*)
Demo
If you want that the regex match your two word try :
(?:Wertmindernde Faktoren|Gebrauchsspuren.*)\n(.*(?:\n.+)*)
Demo 2
i'm not familiar with UiPath but from here you can try like this :
Regex.Match(YourPdfText, “(?:Wertmindernde Faktoren|Gebrauchsspuren.*)\n(.*(?:\n.+)*)”).Value
look to Matches activity and here.

Want to a pre and post character for Multiple macthes in regular expression in Notepad++ with single quotes

Want to replace the below data for every word with single quote before and after. Kindly let me know the regular expression for the same. I have used the one ([a-z]|[A-Z]|[0-9]|[:|.|,|-]) which matches all the word and I don't know to replace with which one to get the single quote before and after.
Data(Every data is with a tabbed spaced)
SystemKey CompanyName PhysicalAddressLine1 PhysicalAddressLine2 PhysicalCity PhysicalStateCode PhysicalProvince PhysicalZipCode PhysicalCountryCode TaxId AU SystemID OfficerID MainPhone OpenDate ChangeFlag
15524499 Valley Medical Center hfdfsffgsdhfdsfgsdfgsdfhgdhfgsdfgsgfjgdsContactAddressLine2dsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsddsdsds NULL Renton ww NULL ww12 US NULL 0042585 15524499 6577T NULL 2015-10-15 00:00:00.000 Y
0007736-000 9700 Pico Corp 9700 W Pico Blvd NULL Los Angeles NULL 90035-4700 US 954456131 0007031 0007736-000 0193T NULL 1981-12-29 00:00:00.000 Y
00088700 GATEWAY, INC. 14303 Gateway Place NULL POWAY NULL CA 92064 CA 421249184 0008725 00088700 1209T NULL 1996-08-26 00:00:00.000 Y
00002400 Nash Finch Company 7600 France Ave S NULL Minneapolis NULL ww 554355924 CA 410431960 0008725 00002400 1289T NULL 1993-10-22 00:00:00.000 Y
00006000 BAE SYSTEMS, Inc. 1601 Research Blvd NULL ROCKVILLE NULL MD 20850-3173 CA 223537950 0062635 00006000 1236T NULL 1993-11-23 00:00:00.000 Y
00008714 Schreiber Foods Inc and Affiliated PO Box 19010 NULL GREEN BAY WI NULL 54307-9010 US 391017450 0048114 00008714 0083T NULL 2007-09-25 00:00:00.000 Y
00013455 Border States Industries, Inc. 105 25th Street N fkjsdhjksdhfjsdkfjks Fargo NULL NULL 58102 NULL 450275004 0057221 00013455 1815T NULL 2010-09-30 00:00:00.000 Y
000160000023 Target Corporation 1000 Nicollet Mall NULL MINNEAPOLIS MN NULL 55402 US 043327228 0008725 000160000023 1221T NULL 1993-12-10 00:00:00.000 Y
00043000 JOHNSON BROTHERS LIQUOR COMPANY 1999 SHEPARD ROAD NULL St. Paul NULL NULL 55116-3210 GB 410810551 0008725 00043000 2042T NULL 1993-12-31 00:00:00.000 Y
000590 North Pacific Supply Co Inc 16250 SE Evelyn St NULL Clackamas NULL NULL 97015-9515 NULL 930430692 0042585 000590 4548T NULL 1978-12-31 00:00:00.000 Y
Expected Value
'SystemKey' 'CompanyName' 'PhysicalAddressLine1' 'PhysicalAddressLine2' 'PhysicalCity' 'PhysicalStateCode' 'PhysicalProvince' 'PhysicalZipCode' 'PhysicalCountryCode' 'TaxId' 'AU' 'SystemID' 'OfficerID' 'MainPhone' 'OpenDate' 'ChangeFlag'
'15524499' 'Valley Medical Center' 'hfdfsffgsdhfdsfgsdfgsdfhgdhfgsdfgsgfjgdsContactAddressLine2dsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsddsdsds' 'NULL' 'Renton' 'ww' 'NULL' 'ww12' 'US' 'NULL' '0042585' '15524499' '6577T' 'NULL' '2015-10-15 00:00:00.000' 'Y'
'0007736-000' '9700 Pico Corp' '9700 W Pico Blvd' 'NULL' 'Los Angeles' ' ' 'NULL' '90035-4700' 'US' '954456131' '0007031' '0007736-000' '0193T' 'NULL' '1981-12-29 00:00:00.000' 'Y'
'00088700' 'GATEWAY, INC.' '14303 Gateway Place' 'NULL' 'POWAY' 'NULL' 'CA' '92064' 'CA' '421249184' '0008725' '00088700' '1209T' 'NULL' '1996-08-26 00:00:00.000' 'Y'
'00002400' 'Nash Finch Company' '7600 France Ave S' 'NULL' 'Minneapolis' 'NULL' 'ww' '554355924' 'CA' '410431960' '0008725' '00002400' '1289T' 'NULL' '1993-10-22 00:00:00.000' 'Y'
'00006000' 'BAE SYSTEMS, Inc.' '1601 Research Blvd' 'NULL' 'ROCKVILLE' 'NULL' 'MD' '20850-3173' 'CA' '223537950' '0062635' '00006000' '1236T' 'NULL' '1993-11-23 00:00:00.000' 'Y'
'00008714' 'Schreiber Foods Inc and Affiliated' 'PO Box 19010' 'NULL' 'GREEN BAY' 'WI' 'NULL' '54307-9010' 'US' '391017450' '0048114' '00008714' '0083T' 'NULL' '2007-09-25 00:00:00.000' 'Y'
'00013455' 'Border States Industries, Inc.' '105 25th Street N' 'fkjsdhjksdhfjsdkfjks' 'Fargo' 'NULL' 'NULL' '58102' 'NULL' '450275004' '0057221' '00013455' '1815T' 'NULL' '2010-09-30 00:00:00.000' 'Y'
'000160000023' 'Target Corporation' '1000 Nicollet Mall' 'NULL' 'MINNEAPOLIS' 'MN' 'NULL' '55402' 'US' '043327228' '0008725' '000160000023' '1221T' 'NULL' '1993-12-10 00:00:00.000' 'Y'
'00043000' 'JOHNSON BROTHERS LIQUOR COMPANY' '1999 SHEPARD ROAD' 'NULL' 'St. Paul' 'NULL' 'NULL' '55116-3210' 'GB' '410810551' '0008725' '00043000' '2042T' 'NULL' '1993-12-31 00:00:00.000' 'Y'
'000590' 'North Pacific Supply Co Inc' '16250 SE Evelyn St' 'NULL' 'Clackamas' 'NULL' 'NULL' '97015-9515' 'NULL' '930430692' '0042585' '000590' '4548T' 'NULL' '1978-12-31 00:00:00.000' 'Y'
You may use
(\t)|^|$
and replace with (?{1}'$1':').
It matches and captures a tab into Group 1, and if it matches the tab is enclosed in single quotes. Else, start and end of lines are matched and in that case, a single ' is inserted at those positions.
Details
(\t) - Capturing group 1: a tab
| - or
^ - start of line
| - or
$ - end of line.
Replacement:
(?{1} - if Group 1 matches
'$1' - replace with ', Group 1 value and '
: - else
' - replace with '
) - end of the conditional replacement pattern.
See the screenshot:

Impala with Sas 9.4 : not import data with create table

creating a table with Sas and Impala I can't import data with many columns (more than 1500). The table is created but the data is not written and the following error is generated:
ERROR: CLI execute error: [Cloudera][ImpalaODBC] (110) Error while executing a query in Impala:
[HY000] : AnalysisException: Syntax error in line 1: ...,xxx`) VALUES ( ? , ? , ? , ? , ? , ? , ? , ...
^ Encountered: Unexpected character Expected: CASE, CAST, DEFAULT, EXISTS, FALSE, IF, INTERVAL, NOT, NULL, TRUNCATE, TRUE, IDENTIFIER
Thank you
I try to create a view or a table with engine SAS Impala (ODBC impala ClouderaImpalaODBC-2.5.36.1009-1.x86_64) RedHat 6.8. And I get this error:
ERROR: CLI execute error: [Cloudera] [ImpalaODBC] (110) Error while executing a query in Impala: [HY000]: AnalysisException: Syntax
error in line 1: ... King ((a.trns_dt between {d '31.10.2015'} and {d '^ 2 ... Encountered:
Unexpected character Expected: CASE, CAST, EXISTS, FALSE, IF, INTERVAL, NOT NULL, TRUNCATE, TRUE, IDENTIFIER Caused BY:
Exception: Syntax error
We have seen that characters that are passed impala can not read such. "{}".

How are numbers matched in OSM Nominatim Geocoder search?

Here is one things that I cannot make sense of how Nominatim handles numbers (at least in Barcelona):
Searching for Passeig de Gràcia and appending numbers 38 or 1, or 20 all returns the same set of results. I don't know where it's matching '38', or '1', or '20' because they are not in the results as fields.
Searching for Calle Mare de Deu dels Desemparats 18 is not returning any result but removing 18 returns 1 result.
Why does the service appear to be lenient to the number search parameters of Passeig de Gràcia while strict with Calle Mare de Deu dels Desemparats?

APEX - Error Returning SQL Query with Date from PL/SQL

I am new to using APEX PL/SQL and apologise in advance if my question has been covered already. I believe have searched exhasutively for an answer.
I have a standard query that works exactly as it should as a source for a region, but requires conversion to PL/SQL so I can process an LOV returned from a shuttle I am going to add.
This is the critical part of the working query:
select METRIC_DEFINITION_ID,
METRIC_NAME,
sum(decode(START_DATE, '01-JUN-12', VALUE)) as "Jun 2012"
from ... (a substantial query that works)
When I attempt to return this from a PL/SQL block:
BEGIN
return 'select METRIC_DEFINITION_ID,
METRIC_NAME,
sum(decode(START_DATE, ' '01-JUN-12' ', VALUE)) as "Jun 2012"
from ... (a substantial query that works)';
END;
I receive the error message:
(ORA-06550: line 9, column 33: PLS-00103: Encountered the symbol "01-JUN-12"
when expecting one of the following: * & = - + ; < ...
as if the compiler is expecting an operator.
I have tried
...TO_DATE(' '01-JUN-12' ')...
with no success. Passing the string to a variable and returning that makes no difference either.
All the documentation I have read suggests my original should work.
Does anyone know if there is different syntax for 'decode' in this context (APEX source for a region), or am I missing something glaringly obvious here?
All suggestions appreciated.
Cheers,
Jason
===========
Adding the complete query, as requested. Note the line
and METRIC_COLLECTION.METRIC_COLLECTION_ID IN :P44_COLLECTION_SELECTOR)
currently only works if a single item is selelcted in the shuttle named P44_COLLECTION_SELECTOR, hence the need to learn PL/SQL.
Dates will be based on inputs in the long run - this is a POC.
select
METRIC_DEFINITION_ID,
METRIC_NAME,
sum(decode(START_DATE, '01-JUN-12', VALUE)) as "Jun 2012",
sum(decode(START_DATE, '01-JUL-12', VALUE)) as "Jul 2012",
sum(decode(START_DATE, '01-AUG-12', VALUE)) as "Aug 2012",
sum(decode(START_DATE, '01-SEP-12', VALUE)) as "Sep 2012",
sum(decode(START_DATE, '01-OCT-12', VALUE)) as "Oct 2012",
sum(decode(START_DATE, '01-NOV-12', VALUE)) as "Nov 2012"
from
(select
METRIC_DEFINITION.METRIC_DEFINITION_ID as METRIC_DEFINITION_ID,
METRIC_DEFINITION.METRIC_NAME as METRIC_NAME,
METRIC_VALUE.START_DATE as START_DATE,
METRIC_VALUE.VALUE as VALUE
from
METRIC_VALUE METRIC_VALUE,
METRIC_DEFINITION METRIC_DEFINITION
where
METRIC_DEFINITION.METRIC_DEFINITION_ID=METRIC_VALUE.METRIC_DEFINITION_ID)
where METRIC_DEFINITION_ID IN
(select
METRIC_COLLECTION_MAP.METRIC_DEFINITION_ID as METRIC_DEFINITION_ID
from METRIC_COLLECTION_MAP METRIC_COLLECTION_MAP,
METRIC_COLLECTION METRIC_COLLECTION
where
METRIC_COLLECTION.METRIC_COLLECTION_ID=METRIC_COLLECTION_MAP.METRIC_COLLECTION_ID
and
METRIC_COLLECTION.METRIC_COLLECTION_ID IN :P44_COLLECTION_SELECTOR)
group by METRIC_DEFINITION_ID, METRIC_NAME
Why did you put spaces in between you quotes?
Try changing:
sum(decode(START_DATE, ' '01-JUN-12' ', VALUE))
To:
sum(decode(START_DATE, ''01-JUN-12'', VALUE))
I Figure this because:
execute immediate 'select to_date(' '01-JUN-12' ') from dual';
returns the same error.