My requirement is getting data from db and creating a csv file with that. I followed the below steps.
I got the data from db with my required columns say col1,col2 and col3. When i am trying to append everything to a string, i am not getting expected resultSet. I first initialized errorData string variable with empty string.
You can append “\r\n” after “%getTracedataOutput/results/TID%” like “%getTracedataOutput/results/TID%\r\n”, then you will get the errorData like:
Save the errorData string into a file named whatever.csv, you don’t need to do something to maintain the columns, Excel will do it.
I tried a sample service my errorData looks like bid1,tid1,error1 bid2,tid2,error2 bid3,tid3,error3
You can tokenize the string based on space character and then remove the comma if you need (customize the code).
valueList will look like
Pass this as your second input to string concat.
%Mahesh.SAG:getTracedataOutput/getTracedataOutput/results/BID%,%Mahesh.SAG:getTracedataOutput/getTracedataOutput/results/TID%,%Mahesh.SAG:getTracedataOutput/getTracedataOutput/results/ERROR%[one space at last]
When i am writing everything to a string list and finally when i am passing it to a fileWriter service,it is just taking very 1st line of String list and writing to a file (is it just because fileWriter takes string as an input ).
When i tried differently like keeping everything in to a single variable say –
final String : bif1,tif1"\r\n"bif2,tif2"\r\n"bif3,tif3"\r\n", when i am writing this to a file it is writing file content too with the same data instead of appending new line in place of “\r\n”.