简体   繁体   English

在 Notepad++ 和 Informatica 中转换以下源文件。 查看给定的源表和我想要的 Output 表

[英]Convert Below Source File in Notepad++ & Informatica. See the Given Source Table & Output Table I Want

Source Data -源数据 -

Cust_Id,Cust_Name,Cust_Address,Cust_Salary
1,Name1,Address,12,Road,40,10000
2,Name2,Addressline,2,15,20000
  1. First Scenario, I Want to Convert this Flat File Like Below and Send to the Target Table (Oracle) By using Informatica Powercenter.第一个场景,我想像下面这样转换这个平面文件并使用 Informatica Powercenter 发送到目标表 (Oracle)。
  2. Second Scenario, I Want to Replace First 2 Columns Commas (Cust_Id, CustName) with Pipe Delimited and Keep the Commas in Address Column Value how to Replace only First Two Column Commas in Notepad++.第二个场景,我想用 Pipe 分隔替换前两列逗号(Cust_Id,CustName)并保留地址列值中的逗号如何在 Notepad++ 中仅替换前两列逗号。
  3. Third Scenario, I Want to Convert this Same Source Flat File And Implement Same Logic as like Second Scenario in Unix.第三个场景,我想转换这个相同的源平面文件并实现与 Unix 中的第二个场景相同的逻辑。
  4. Fourth Scenario, Write Query in Oracle for this Scenario and Display Result in Separate, Separate Columns.第四种场景,在Oracle中为这个场景编写查询,并在单独的、单独的列中显示结果。 For Ex: - Desired Output in Oracle例如:- 在 Oracle 中需要 Output
Cust_Id客户编号 Cust_Name客户名称 Address地址 Salary薪水
1 1个 Name1姓名1 Address,12,Road,40地址40号路12号 10000 10000

Desired output in Informatica & Notepad ++在 Informatica 和记事本中需要 output ++

Cust_Id,Cust_Name,Cust_Address|Cust_Salary
1|Name1|Address,12,Road,40|10000
2|Name2|Addressline,2,15|20000

use an expression transformation to create 3 columns from one column.使用表达式转换从一列创建 3 列。 Read the data in a single column.读取单列中的数据。

in_inp_data
out_Cust_Id = substr(in_inp_data,1, instr(in_inp_data,','))
var_length_cust_name= instr(in_inp_data,',',2) - instr(in_inp_data,',') -1
out_Cust_name =  substr(in_inp_data,instr(in_inp_data,',')+2,var_length_cust_name)
out_Cust_Address = substr(in_inp_data, instr(in_inp_data,',',2)+1)
Cust_Salary = substr(in_inp_data, instr(in_inp_data,',',-1))

Explanation - 1,Name1,Address,12,Road,40,10000 substr(in_inp_data,1, instr(in_inp_data,',')) - this produces 1 because it cuts first character till first comma which is 1.解释 - 1,Name1,Address,12,Road,40,10000 substr(in_inp_data,1, instr(in_inp_data,',')) - 这会产生1 ,因为它将第一个字符剪切到第一个逗号 1。
substr(in_inp_data,instr(in_inp_data,',')+2,var_length_cust_name) - this produces Name1 because it cuts string after first comma upto length of name. substr(in_inp_data,instr(in_inp_data,',')+2,var_length_cust_name) - 这会产生Name1 ,因为它将第一个逗号之后的字符串剪切到名称的长度。

substr(in_inp_data, instr(in_inp_data,',',-1)) - this extracts last string before first comma from the end of string which is salary. substr(in_inp_data, instr(in_inp_data,',',-1)) - 这会从字符串末尾提取第一个逗号之前的最后一个字符串,即薪水。

Fourth Scenario Answer (Oracle/SQL Developer)第四种场景答案(Oracle/SQL Developer)

Table Structure表结构

Create Table Cust_Data
(Input_Data Varchar2(255));
            
Insert Into Cust_Data Values ('1,Name1,Address,12,Road,40,10000');
Insert Into Cust_Data Values ('2,Name2,Addressline,2,15,20000');
            
Select * From Cust_Data;

Syntax句法

Select
  Substr (Input_Data, 1,
  Instr(Input_Data,',')-1) Cust_Id,
  Substr (Input_Data,
  Instr (Input_Data, ',', 1) +1,
  Instr(Input_Data,',', 1, 2) - Instr(Input_Data,',')-1) Cust_Name,
  Substr (Input_Data,
  Instr (Input_Data, ',', 1, 2) +1,
  Instr(Input_Data,',', -1, 1)- Instr (Input_Data, ',', 1, 2)-1) Cust_Address,
  Substr (Input_Data,
  Instr (Input_Data, ',', -1, 1) +1 ) Salary
From Cust_Data;

First Scenario Answer (Informatica Powercenter)第一个场景答案 (Informatica Powercenter)

Expression Transformation
in_Input_Data (nstring)
out_Cust_Id (integer) = SUBSTR (in_Input_Data,1, INSTR (in_Input_Data,','))
var_Length_Cust_Name (integer) = INSTR(in_Input_Data,',',1, 2) - INSTR(in_Input_Data,',') -1
out_Cust_Name (nstring) =  SUBSTR(in_Input_Data,INSTR(in_Input_Data,',', 1)+1,v_Length_Cust_Name)
out_Cust_Address (nstring) = SUBSTR(in_Input_Data,INSTR(in_Input_Data,',',1, 2)+1)
Cust_Salary (Double) = SUBSTR(in_Input_Data,INSTR(in_Input_Data,',',-1,1)+1)

Link all this Output Port to Target.将所有此 Output 端口链接到目标。

Second Scenario Answer (Notepad++)第二个场景答案(Notepad++)

  1. Open Notepad++打开记事本++
  2. Press Ctrl + H Button.Ctrl + H按钮。
  3. In Find What Zone: ^(.+?),(.+?),(.+),(.+?)$查找区域中: ^(.+?),(.+?),(.+),(.+?)$
  4. In Replace With Zone: $1|$2|$3|$4替换为区域: $1|$2|$3|$4
  5. Select Wrap Around . Select环绕
  6. Select Regular Expression . Select正则表达式
  7. And Click Replace All .然后单击全部替换

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 针对Informatica中的源运行SQL并将结果导出到目标表 - Running SQL against the source in Informatica and exporting results to a target table 我在 informatica 中使用的以下表达式。 但是这种表达方式对我不起作用。 它显示错误。 任何人请帮助解决这个问题。谢谢 - The below expression I used in informatica. But the expression is not working for me. it shows error. Anyone please help to resolve this issue.Thanks (SQL) 我想要给定表的特定行输出 - (SQL) I want a specific row output from the given table 是否有查询来检索 informatica 中特定映射的所有源表名和目标表名? - Is there a query to retrieve all source table names and target table names of a particular mapping in informatica? 我想通过在源限定符中运行查询来替换SQL中的交叉联接,从而替换Informatica中的Normal Join? - I want to replace Normal Join in Informatica by Cross join in SQL by running a query in source qualifier? 我有如下表所示的源,目标和KMS列,我需要基于KMS列 - I have table as shown below with source,Target and KMS columns and i need out based on KMS columns 我正在尝试使用 python sql 访问存储在雪花表中的数据。 下面是我要访问的下面给出的列 - I am trying to access the data stored in a snowflake table using python sql. Below is the columns given below i want to access 在给定条件下将行从源表复制到新表 - Copy rows from source table to new table given condition 我想按以下两种品质按表订购 - I want to order by table with below two qualities 我在 Notepad++ 中可以看到的最大记录数是多少? - What is the maximum number of records i can see in Notepad++?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM