First create a csv file in excel and save it in csv format.
Create a SOA application -> SampleCSVApp and a SOA
project inside it CSVTest
Drop a FileAdapter from Component Palette and give a name
like WriteCSV select the write operation Type.
Next step select the output Directory and give a file name.
In next step select
the native format builder by clicking the icon next to search icon
Select delimited option
Now here in this step you will browse the .csv file that we have created earlier
Select
the datatypes of the column and give
element name
Check use the first record as the field names and select
next now you will see a xsd is generated with specified type and name.
You can test it by clicking on Test and finish.
Now create a one way bpel process and in input parameter
select the same sample xsd element.
Now use a transform activity to send input data to file.
The generated file will not have header names details in it.if you want to add the header name details in generated csv file .for the the generated xsd file need to be modified and these attributes need to be added into the xsd as shown below
nxsd:hasHeader="true"
nxsd:headerLines="1"
nxsd:outboundHeader="Name,EmpID,DeptID ${eol}"
nxsd:headerLinesTerminatedBy="${eol}"
nxsd:hasHeader="true"
nxsd:headerLines="1"
nxsd:outboundHeader="Name,EmpID,DeptID ${eol}"
nxsd:headerLinesTerminatedBy="${eol}"
Deploy it and test it
Will the output include the headers(Name,EmpID,DepID)? Or just the values
ReplyDeleteHi Mustapha,
Deletethe geneated file will only have values not the header if you want to put the header also for that i have modified the blog the will to add the headers details
Regards,
Pankaj
HI Pankaj,
ReplyDeleteIs it possible to pass different filed to different files.
I have file files with one schema. Five file names having five different field names like (1st file having product,description and for 2 nd file company,description) with same manner 5 files having with different field names in one BPEL. Is it possible to pass like that. If possible how can you please help me in this regard.
ReplyDeletePlease advise it is very urgent.
ReplyDeleteHi Hari,
DeleteThe requirement that you have you want to generate 5 csv file using a single xsd(File adapter) with different header values.but here for the header ,i have used nxsd:outboundHeader that can't be changed at runtime.
can you share your xsd details and usecase so that i can look for a workaround
Thanks,
Pankaj
Hi,
ReplyDeleteI have a requirement to read n write a CSV file using file adapter. My problem is that the file has first row with only 6 comma separated values and rest of the file with 21 comma separated values. Can I read the whole csv file in one go and write to target file using write adapter.
Please guide how to read two different type of structure i the same file.
Thanks in advance.
With each batch it is adding the header all the time. Is there a way to only add the header in the first batch only
ReplyDeleteI do have the same question?
ReplyDeleteHi i am also facing same issue did you find any solution for this ? If you find any thing please let me know .
DeleteRegards
Nagesh
i am also facing same issue. Kindly let me know if anyone is able to resolve it.
Delete