CSV File: Remove quotes from the file.

Certified Senior Developer

Hello Everyone,

I am converting HTML to CSV using this process nodes and it's working fine. Although I can export data store entity to CSV- but there is different requirement, so I am not using this approach. Please see below screenshot. 

Requirement: When I open that CSV file in Notepad++ I see this:


I need to remove these quotes in a file. How can I achieve this?

Thanks

  Discussion posts and replies are publicly visible

Parents
  • NOTE, if you are only removing quotes from the CSV file, you may be left with values within the quotes that contain a comma that is not intended to be used as a delimiter, this will break your entire file.  This is the purpose of quoting all values within a CSV, which is essentially a standard that all systems designed to accept CSV should honor, in my opinion.

    And what is the data like that is coming into the initial HTML node, from a DB query etc?  Can you utilize an expression rule to build the CSV file?

    In all the CSV files I create, I generate the contents via an expression rule, which gives you full control over the output, then run that into a Text Doc from Template node which only has one placeholder (for the entire text).  As I type this however I realize that all of my CSV files are SFTP'd out, which is where I convert them from .txt to .csv, I'm not sure if we have an other way to change file types in Appian..

  • 0
    Certified Senior Developer
    in reply to Chris

    I am taking data from process variables. because at this time data is not saved into database which is the reason I am not using Export data store entity to CSV. 

    What I have done. I have used node HTML Doc from Template. In this template I have designed a table form data as mentioned below..

     <HTML>
     <head></head>
        <BODY>
    <form>
           <table name="Add" style="border:2px solid black" width="100%" border="1" cellpadding="5" cellspacing="0">
                    <tr>
                      <th><label> <b> Name </b> </label> </th>
                      <th><label> <b>  Date </b> </label> </th>
                      <th><label> <b> Address </b> </label></th>
                      <th><label> <b> Department </b> </label></th>
    				  <th><label> <b> Country </b> </label> </th>
                   </tr>
    			    ###details###
               </table>
    </form>
    </BODY>
      </HTML>


    In ###details###- I have created a rule that will get data from process variables. Followed by that - all data converted into csv file using HTML to CSV smart service.

  • 0
    Certified Lead Developer
    in reply to manjit.1486

    it seems like it's adding a whole extra set of blanks at the end (along with the hardcoded commas you have separating them), though the exact cause is a little hard to tell without seeing an example value for "pv!empDetails".

  • I would definitely recommend creating an expression rule for this, vs adding the code directly within the process - this way we can utilize different test cases, etc, much more easily.

    Good news on the Text Doc from Template working to retain a .csv extension, I could have swore I tried that unsuccessfully in the past - but guess not!  Or it was ages ago Slight smile

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    You can refer this one:
      

  • 0
    Certified Senior Developer
    in reply to Chris

    Yes, I have created a rule for the same. But for now i am just testing it directly. Anyways, I put a rule before proceeding this.

  • Agree with Mike we need more information on pv!empDetails.  Is this single or multi-valued?  If it is single, the unions in and a!forEach() are not necessary. If it is multiple, the unions are still confusing to me, and will likely confuse the output as well (and you should be using fv!item.dataPoint. Are you trying to reduce multiple exact rows into 1, etc?

  • 0
    Certified Senior Developer
    in reply to Chris

    It's multivalued. 
    Actually data is coming right in multiple rows in CSV. The only thing is when I open this file in editor it shows commas at the end of array.

    = a!localVariables(
      fv!item: pv!empDetails,
    
      joinarray(
        a!forEach(
          items: fv!item,
          expression: a!localVariables(
            local!currentUserIndices: wherecontains(
              fv!item,
              touniformstring(fv!item.name)
            ),
            concat(
            
                fv!item.name_txt, ,
              ",",
             
                fv!item.address_txt, ,
              ",",
              fv!item.dept,
              ",",
             fv!item.side,
              ",",
             fv!item.city,
    
            )
          )
        ),
        char(13) & char(10)
      )
    )


    Please ignore the union for the time. I have updated the code. 

  • You can also remove the a!localVariables from within the a!forEach since local!currentUserIndices is not used anywhere.

    Additionally, note the extra commas within the concat after name, address.

    Try this alone in the a!forEach expression - for safety you will want to remove commas from within each of the values as well, while they may not be likely, and single one will break your file (since we are no longer wrapping in quotes):

    concat(
      stripwith(fv!item.name_txt,","),
      ",",
      stripwith(fv!item.address_txt,","),
      ",",
      stripwith(fv!item.dept,","),
      ",",
      stripwith(fv!item.side,","),
      ",",
      stripwith(fv!item.city","),
    )
    

  • 0
    Certified Senior Developer
    in reply to Chris

    Okay, thanks. let me try with this.

  • 0
    Certified Senior Developer
    in reply to manjit.1486

    It's not working. Let's make it simple.
    I have checked when I delete last blank row in CSV file and save it. After that I open that csv file in editor and there were no commas. Disappointed

  • 0
    Certified Senior Developer
    in reply to manjit.1486

    I think we just need to remove blank row that is added as a last record in CSV. That's why it shows commas after last record in editor file.

Reply Children
No Data