One Star

[resolved] row in the CSV file

Hi,
I would like to add to my csv file on the top some extra row to look like below, I am not sure how to do it using talend.
I have use a three different files from where I am doing mapping and look up but on the end when I insert to my csv file and just getting normal column population not sure how to make these empty rows before I get title for my second part.
Any help is welcome.
Thanks
Zeljka
colum1 colum2 column3
text,
text ,
text ,
title1 title2, title3
tesxt text, text,
text, text text
text text text
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] row in the CSV file

Hi Zeljka
I am back to you, I understand your request now, you need redesign the job like this:
the first part(output the result to a file as you done, let's say it is test.csv)
|
the second part---tFileOutputDelimited(output the result to a temporary file, eg: temp.txt, note that check the box 'include header')
|
tFileInputFullRow(Read the temporary file temp.txt line by line)--main->tFileOutputDelimited(output the result to test.csv, note that check the box 'append')
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
28 REPLIES
One Star

Re: [resolved] row in the CSV file

Hi,
I put some screenshots for a job that uses a tForeach to write out the header lines (text1, text2, and text3) and follows this up by appending a standard input/tMap/output.
http://bekwam.blogspot.com/2011/02/quick-report-with-talend-open-studio.html
You could also use a block of Java IO in the prejob routine.
-Carl
One Star

Re: [resolved] row in the CSV file

Hi Carl,
Thanks for your link but I still do not understand how to make my output to look as I wanted. I actually need on my existing file to add these
text,
text,
text,
text
columns and also in my case I am having 2 different files as input plus I am having lookup file and all these is mapped as one to produce one output file.
I have looked your example and had try but I am not sure when I use tForeach and link with tIterateToFlow I will need some schema but which one I will use .
I have to add I am pretty new Talend user and not really familiar with all these functionalaty.
Could you please try to give me some more explanation .
Thanks
Zeljka
One Star

Re: [resolved] row in the CSV file

Hi,
I updated the blog post. I added screenshots showing the two schemas. Both schemas are used to write to the same CSV file.
The first schema describes a single field of type string. This will write out the text values defined in the tForeach component.
The second schema is probably more familiar. It describes the data that will make up most of the report. It can be taken from the repository. My example is writing contact info (first name, last name, etc.) using this second schema.
http://bekwam.blogspot.com/2011/02/quick-report-with-talend-open-studio.html
-Carl
One Star

Re: [resolved] row in the CSV file

thanks,
I actually need to add the first 9 rows to my csv file , see my an attached file.
I hope your way is going to work..
Thanks
Z
One Star

Re: [resolved] row in the CSV file

An attached file this time
One Star

Re: [resolved] row in the CSV file

Hi Carl,
I have tried your way but still I can't make my csv file to look as I wanted.
I had try to creat two different input file one with first part of my test and second with other text below and to map but I can't get layout as I wanted.
Zeljka
One Star

Re: [resolved] row in the CSV file

A few things to check
1. Use two tOutputFileDelimited components with the second one set to Append
2. Make sure that the second subjob -- the one writes the data out -- is run after the first with a Subjob OK
One Star

Re: [resolved] row in the CSV file

I had try to have two output files as what Is show on the images, I have in my log file what I want but cant get in my csv input to be like that..
see below..
One Star

Re: [resolved] row in the CSV file

schema
One Star

Re: [resolved] row in the CSV file

I posted a video tutorial on this. See if it helps http://youtu.be/DdTBSguTjzc?a .
One Star

Re: [resolved] row in the CSV file

hi,
Thanks for your advice ..
I have done exactly how you did post on youtube but my second title not showing up.. can't figure out why as I am not doing anything different.
Z
One Star

Re: [resolved] row in the CSV file

Is it outputting "#BEGIN HEADER", "#SENDER ID", and the remaining fields but not "#CLIENT ID"?
One Star

Re: [resolved] row in the CSV file

hi,
I have done everything as you suggested on your video but from my images you can see that I have still not having title in second part of the text even if I folow your instruction.
any an indea what can cause that..

Thanks
Zeljka
One Star

Re: [resolved] row in the CSV file

Yes I can see my
#Header,
#SenderID etc
but can't see the title of the second set data
One Star

Re: [resolved] row in the CSV file

I am not sure if I am clear,
the first part is coming very good, I am having all my data from the tForeach part,
however my second file having title before every single column
test,
test,
test,
test
.
.
.
Title title title title
text text text text
should loook like this but I am having as I sowed on my image,
the second part is only text but not title at all
Thanks
Zeljka
One Star

Re: [resolved] row in the CSV file

Is Trade set to Header=0, Footer=0?
One Star

Re: [resolved] row in the CSV file

No ,
My Trade file header is = 1 and footer = 0
but in other file it is set it both to be = 0
One Star

Re: [resolved] row in the CSV file

Also is any chance that I can pass any variable ,
I wanted in the first set of the data to put some date to be change in loop like current date where is Date stated, or no of Version or no of the Row.
is this posible as all these row is under one column.
Zeljka
# BEGIN HEADER VERSION 1.1
# SENDERID:
# CLIENTID:
# DATE:
# FILETYPE:
# VERSION:
# ROWS:
# SEPARATOR:
# END HEADER
One Star

Re: [resolved] row in the CSV file

Use the Java concatenation operator to join a variable to the header in the tForeach values.
Some examples
"#HEADER: " + context.DATA_DIR
"#DATE: " + TalendDate.getCurrentDate()
One Star

Re: [resolved] row in the CSV file

Thank you very much for these ...
do you have any idea why header of my second file is not displaying.
Z
One Star

Re: [resolved] row in the CSV file

Thanks Walkerca
The code with add Variable working very good the only outstanding issue is that I still can't desplay title of my main file.
If I run main file with out tForeach part my Title is there but when I make link between these two
Please see these two images one is with title and one is with out when I link it with tForeach
One Star

Re: [resolved] row in the CSV file

images
One Star

Re: [resolved] row in the CSV file

From a couple posts back..."My Trade file header is = 1 and footer = 0"
Have you tried header=0?
One Star

Re: [resolved] row in the CSV file

Hi,
I am able to sort date in my Rows where I am having DATE but I as I new in Talend not sure how I can create this line
"#HEADER: " + context.DATA_DIR , I am not sure how to create context for exisitng tForeach job
Thanks
Zeljka
One Star

Re: [resolved] row in the CSV file

Sorry I just saw your post about my Header = 1 ..
yes I have even tried to change to be Header = 0 and still not showing ...
Z
One Star

Re: [resolved] row in the CSV file

hi,
I have try any solution to bring my title of my main file.
I do not have problem to do my data as look like below
text
text
text
however when I become to bring titile of my part look like below I am just losing my title even if I tick Include header and append. this is quite important for me and so far I couldn't find any solution.
Is anyone who can help.
Thanks
Z
title title title title
text text text text
text text text text
Community Manager

Re: [resolved] row in the CSV file

Hi Zeljka
I am back to you, I understand your request now, you need redesign the job like this:
the first part(output the result to a file as you done, let's say it is test.csv)
|
the second part---tFileOutputDelimited(output the result to a temporary file, eg: temp.txt, note that check the box 'include header')
|
tFileInputFullRow(Read the temporary file temp.txt line by line)--main->tFileOutputDelimited(output the result to test.csv, note that check the box 'append')
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] row in the CSV file

Hi Shong,
Thank you , this way is working finally... ; )

Thanks
Zeljka