Uploading CSV files into database

0 votes

I have various input files with fixed number of rows which always begin with the following 7 lines of information:

"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…

Note: There are two different delimiters used comma(,) and semi-colon(;).

I want to import the above data into a SQL database table. I know the process of importing data from the source file into a database but my problem is how do I append the new information in the header rows of every relevant table?

The final output should look like below:

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

Please suggest how can I perform this.

Apr 17, 2018 in Talend by misc.edu04
• 1,450 points
1,011 views

1 answer to this question.

0 votes

In order add the header data into all the files, store them as global variables.

Try following the below steps:

  1. Add tFileInputDelimited(x2), tJavaRow, tMap and tLogRow components in the workspace and connect them as shown below:

enter image description here

  • In the tfileInputDelimited_1 component set the schema(key,value), separator (",") and limit 7.

  • In the tJavaRow component write : globalMap.put(input_row.key, input_row.value);

  • In the tFileInputDelimited_3 component set the schema (TXN_tijd, TXN_Nr, Kostenplaats_naam, … ), separator (";") and header 8

  • Double click on tMap component to open the tMap editor. Then map the input tables with the output as shown below:

enter image description here

Hope this works for you.

answered Apr 17, 2018 by geek.erkami
• 2,680 points

Related Questions In Talend

0 votes
1 answer

How to load a set of files into database using Talend

Using tFileList component,  you can read all the files present ...READ MORE

answered Apr 17, 2018 in Talend by code.reaper12
• 3,500 points
6,156 views
0 votes
1 answer
0 votes
0 answers

How can I use talend to extract data from Oracle and import the data into a MSSQL database?

We currently have around 100 Oracle tables ...READ MORE

Nov 4, 2020 in Talend by umesh
• 150 points
2,550 views
0 votes
2 answers
0 votes
1 answer

Looping through all the schemas in Talend

It is really simple to make tOracleInput ...READ MORE

answered Apr 11, 2018 in Talend by code.reaper12
• 3,500 points
1,882 views
0 votes
1 answer

Adding third party libraries into the Talend project

You can add the 3rd party libraries ...READ MORE

answered Apr 9, 2018 in Talend by code.reaper12
• 3,500 points
3,949 views
0 votes
1 answer

tWaitForFile component insufficiency in Talend

Regarding your first issue, tWaitForFile component provides ...READ MORE

answered Apr 11, 2018 in Talend by geek.erkami
• 2,680 points
2,484 views
0 votes
1 answer

Downloading files using Talend Studio

As per my understanding, I think first ...READ MORE

answered Apr 12, 2018 in Talend by code.reaper12
• 3,500 points
2,401 views
0 votes
1 answer

Assigning Context Variable from the database value

I think if you want to link ...READ MORE

answered Apr 19, 2018 in Talend by geek.erkami
• 2,680 points
2,627 views
0 votes
1 answer

Comparing 2 files and keeping the unique entries

Hi, To get the unique records from the ...READ MORE

answered Apr 20, 2018 in Talend by geek.erkami
• 2,680 points
1,840 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP