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 Senior Developer
    in reply to manjit.1486

    We can achieve this ting by using CSV file template in "Text doc from template smart service". It worked.

  • 0
    Certified Lead Developer
    in reply to manjit.1486

    Sorry, yes now that you mention it, I did know that would be a workable alternative: namely, to create a (text) template that's actually a filename with ".csv" extension.  Appian doesn't enforce the extension (and keeps the original) despite it being "text from template".

    I reiterate my original warning that the file you're generating here is no longer an actual CSV file (despite the extension you're keeping), since the quoted fields are a part of the CSV file format for parsing sake.  If you're lucky the resulting file might still parse correctly by a CSV reader.

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

    Yes. Actually it was the same result of CSV file that I got before. Therefore, CSV file seems to be perfect and parsed properly, also in editor I can this file without quotes.

  • 0
    Certified Senior Developer
    in reply to manjit.1486

    Can anyone guide how to remove these commas from this file? This file is basically a CSV file that I open in editor.

  • 0
    Certified Lead Developer
    in reply to manjit.1486

    AFAIK those commas indicate the presence of columns (exported to the CSV) that didn't have any data in them.  You could always just pass the text through some function that removes any comma(s) at the end of a line of text... but it might be more worth your time investingating why they're appearing in the first place.

  • 0
    Certified Senior Developer
    in reply to Mike Schmitt

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

    Actually, it suddenly appears, Earlier it was working fine- although, I have checked the previous versions as well. But no difference in code. Can you( ) please go through the code?

  • 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.

Reply Children