Talend:如何在 SQL 中导入这个 csv 文件? [英] Talend: How to import this csv file in SQL?
问题描述
我收到了来自 BP 的 CSV 文件,内容涉及我们的燃料和油路交易.
I receive CSV files from BP, regarding our fuel and tol transactions.
文件总是以这7行信息开头,详细信息中没有包含.
The file begins always with these 7 lines of information, which is not included in the details.
如何使用 Talend 将此数据导入 SQL 中的 1 个表中?
How can I import this data into 1 table in SQL using Talend?
我知道如何将 csv 文件中的数据导入 SQL,但如何将 de 标头中的信息(Factuur 编号、Factuur 日期...)添加到 de details 中的每一行.
I know how I can import data from a csv file into SQL, but how can I add the information in de header (Factuur number, Factuur Date, ...) to every row in de details.
"Factuur","12345678"
"Datum","27/02/2012"
"Totaal:","1"
"Totaal netto:","99,18"
"Totaal bruto:","107,13"
"Verzamel factuurnummer:","1234567890A"
"Valuta:","EUR"
"TXN tijd (dd/mm/jj)","TXN Nr","Kostenplaats naam","Truncated...
"11/02/2012 02:22";"00000222";"";"722222";"Truncated...
"12/02/2012 02:22";"00000223";"";"722222";"Truncated...
"13/02/2012 02:22";"00000224";"";"722222";"Truncated...
SQL 中导入的行应如下所示:
An imported row in SQL should look like:
Factuur Datum ... TXT tijd TXN Nr. ...
12345678 27-2-2012 11-2-2012 02:22 00000222
12345678 27-2-2012 12-2-2012 02:22 00000223
推荐答案
我们可以将 header 的数据存储为全局变量,然后像往常一样在 Tmap 中使用它们:
We can store the data of the header as global variables then use them in Tmap as usual:
- TfileInputDelimited_1:模式(键,值),分隔符,"和限制 7
- tJavaRow:
globalMap.put(input_row.key, input_row.value);
- tFileInputDelimited_3 : schema(TXN_tijd, TXN_Nr, Kostenplaats_naam, ..), 分隔符 ";"和标题 8
- 地图:
而且效果很好!
这篇关于Talend:如何在 SQL 中导入这个 csv 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!