Get Involved. Join the Conversation.


    Cesar Tepetla Corte
    Read CSV line by line and assemble a template with specific...
    Topic posted May 25, 2019 by Cesar Tepetla CorteBronze Medal: 1,250+ Points, tagged API, Cloud, Events, Integration, Mapping, Orchestration, Process, REST, SOAP, Web Services, xml 
    64 Views, 3 Comments
    Read CSV line by line and assemble a template with specific data from the csv file.
    Read CSV line by line and assemble a template with specific data from the csv file.Read CSV line by line and assemble a template with specific data from the csv file.

    Hi, I'm all working on an integration that reads a .csv file and from each recovered line I want to take only certain fields and create a template to load it into a lookup
    I tried to create the template within the for-each that retrieves line by line but it generates a file for each line and that's not my focus, on the contrary I want all the lines in a single file.

    Any idea how to do this?
    Any opnion and comment is appreciated.



    • Kanchankumar Khedkar

      I have not seen your code, but i think you need to select append to existing file. Also, make sure that all the file write operations within for-each are using same fileName. so, you should add filename while writing to file (this is a parameter fileName where mapping). 

      Another good option is to write (append to file) using stage action in loop and then outside loop move file from Stage to actual directory you want to write to (either FTP or FileAdapter.

      Third instead of writing a individual record, if you can write all records in a single go but then it might not be always feasible based on usecase.

      Thank you.

      • Cesar Tepetla Corte

        Hi Kanchankumar,

        Writing each line in the same file is not a good solution because in the XML schema for stage write I have specified the header of the template so when writing each line in the same file it will be repeated, for example:




        That is why you also perform writing on the Write inside the loop
        is not an alternative because I will not write the file in an FTP but I must invoke the web service that imported the template to UCM and use another web service to load the template in the lookup that I need.


        • Hemen Shah

          Before start of loop, first write only header in stage write and then in side loop write in the same file with append mode and write your actual line data


          Take one global variable, assign your header first and then concanate your required column for each line in that variable and then write in stage file