Hi Arushi,

You can use WSO2 EI Data-mapper mediator [1]
<https://docs.wso2.com/display/EI640/Data+Mapper+Mediator> to process CSV
to JSON data transformations. Please refer [1]
<https://docs.wso2.com/display/EI640/Data+Mapper+Mediator> and [2]
<https://medium.com/@dilsimchandrasena/convert-csv-to-json-using-a-data-mapper-47728f837a23>
for
more details.

Thanks & Best Regards,
Prabushi

[1] - https://docs.wso2.com/display/EI640/Data+Mapper+Mediator
[2] -
https://medium.com/@dilsimchandrasena/convert-csv-to-json-using-a-data-mapper-47728f837a23

On Thu, Apr 4, 2019 at 11:57 AM <[email protected]> wrote:

> Hi,
>
> I am trying to convert csv file to json in wso2. I am stuck and don't know
> how to proceed. Can you please help. Below is the code and result has data
> in csv format.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <sequence name="test2" trace="disable" xmlns="
> http://ws.apache.org/ns/synapse";>
>     <fileconnector.read>
>
> <source>file://home/wso2carbon/wso2ei-6.4.0/repository/logs/csvfiles/DS001_Operating_System_01012018.csv</source>
>         <contentType>text/plain</contentType>
>         <filePattern>.csv</filePattern>
>     </fileconnector.read>
>     <log>
>         <property name="read_file" value="reading contents of file"/>
>     </log>
>     <property expression="json-eval($.text)" name="results_csv"
> scope="default" type="STRING"/>
>     <property expression="get-property('results_csv')" name="result"
> scope="default" type="STRING"/>
> </sequence>
>
>
> File contents are like :;
>
> "Host_Name","Parent_Type","Store_Number","Environment","Operating_system","Comment","End_of_Patch","Target_Patch_Level","Current_Patch_Level","Patches_deployed_Month","Device_Type","Company","Patch_Frequency","Date","File_Name"
> "atlntaj60","Corporate - Availability","Not
> applicable","PROD","Microsoft(R) Windows(R) Server
> 2003","Legacy","Yes","-2","-6","5/1/2015 00:00:00","Corporate-Windows
> Server","LCL","Monthly","3/5/2018
> 00:00:00","DS001_Operating_System_03052018.csv"
> "harnthr62","Corporate - Availability","Not
> applicable","PROD","Microsoft(R) Windows(R) Server
> 2003","Legacy","Yes","-2","-6","5/1/2015 00:00:00","Corporate-Windows
> Server","LCL","Monthly","3/5/2018
> 00:00:00","DS001_Operating_System_03052018.csv"
>
>
> _____________________________________
> Sent from http://wso2-oxygen-tank.10903.n7.nabble.com
>
>

-- 
*Prabushi Samarakoon*
Mobile: +94715434580
Email: [email protected]
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to