App Connect

 View Only
  • 1.  Delete string in CSV file

    Posted Wed November 15, 2023 10:18 AM
    Edited by Ade Odelana Wed November 15, 2023 11:58 AM

    I have a few "Eiffel" entries in the 9th column in a CSV file. How would I write ESQL code for the Compute Node to delete the records / rows which do not have the "Eiffel" entries and then output the result to a new CSV output file. The IBM Integration bus version is IIB version 10. I have specified the filename pattern for the CSV file in the FileInput Node but I get no results in the FileOutput Node. Thanks.


    ------------------------------
    Ade Odelana
    ------------------------------



  • 2.  RE: Delete string in CSV file

    Posted Thu November 16, 2023 02:41 AM

    Hi!

    Have you tried writing any ESQL for this? If so, you can paste it here and we can look at it for you. If you haven't even started, then I would write something like:

    1. Loop through all records from InputRoot
    2. Add an IF statement to match your criteria. 
    3. IF true then copy the current record to output

    Have you checked in f.ex debugger that the file is read (into IIB) correctly? 

    Another tip : When I work with CSV files, I normally make a copy of the file with only f.ex 5 lines. Makes debugging much easier if the file is big. 

    Also - FYI: I think IIB 10 is no longer supported. 



    ------------------------------
    Lars Dehli
    ------------------------------



  • 3.  RE: Delete string in CSV file

    Posted Sun November 19, 2023 11:39 AM

    Hi Lars, thanks for your response.

    Eiffel is in the 6th field, not the 9th field.

    The first 5 entries in the CSV are:

    p1;p1_z;1;usa;colorado;national museum;Paul;

    p2;p2_z;2;france;paris;Eiffel;Colin;

    p3;p3_z;3;brazil;sao paulo;luz station;Matthew;

    p4;p4_z;4;canada;melbourne;Eiffel;Andrew;

    p5;p5_z;5;germany;cologne;kolner dom;Martin;

    I want only the records with Eiffel to be output into the output CSV. The record numbers (3rd field) need to be updated. For example the output for the above CSV will be:

    p2;p2_z;1;france;paris;Eiffel;Colin;

    p4;p4_z;2;canada;melbourne;Eiffel;Andrew;



    ------------------------------
    Ade Odelana
    ------------------------------



  • 4.  RE: Delete string in CSV file

    Posted Mon November 20, 2023 11:42 AM

    Any replies from anyone please?



    ------------------------------
    Ade Odelana
    ------------------------------



  • 5.  RE: Delete string in CSV file

    Posted Mon November 20, 2023 11:56 AM

    What Lars suggested was a good start. He also asked for a sample of your code to see what it is you're currently doing. 

    If you're having trouble not getting records in your output, I'd start with a small file, as Lars suggested, and run the code through the debugger to see if your condition is being triggered accurately. If it is, but you're not getting output, you need to determine why. If not, you need to work on that criteria first.



    ------------------------------
    James E. (Jim) Berube
    Technical Account Manager (TAM) - Specialist, IBM Expertise Connect, IBM Expert Labs
    IBM Software
    ------------------------------



  • 6.  RE: Delete string in CSV file
    Best Answer

    Posted Wed November 29, 2023 06:27 PM

    Never saw any response from you, but this is simple and works.

    Showing Application, Flow and Shared Library with Message Model
    Showing the Message Model defined in the Shared Library
    The ESQL code that only selects rows with Eiffel for output
    Showing the resulting output file.



    ------------------------------
    James E. (Jim) Berube
    Delivery Consultant, IBM Expertise Connect, IBM Expert Labs
    IBM Software
    ------------------------------