Solved

Add double quotes " " to text string and replace coma with pipes delimiter in CSV File

  • 4 August 2022
  • 4 replies
  • 170 views

Badge +1

See below my Workspace to generate a CSV file from a SQL View:

Forum1The CSV looks good except I need to put double quotes (“ “) for certain text strings. For example under Ledger Type column, AA should be ‘AA’.

Forum2Please let me know which of the String Function(s) in AttributeManager I should use to put double quotes around text strings (or other Transformer you deem more efficient):

Forum3Also, how can I replace all the comma separators in the CSV file with pipes character ’|’ instead.

Many thanks!

icon

Best answer by ebygomm 5 August 2022, 10:14

View original

4 replies

Badge +2

@fmesafejde​ There isn't a string function to add quotes. Just use the text editor to add the quotes:

"@Value(Ledger Type)"

You can set the delimiter on the CSV writer parameters when you add the writer to your workspace: Delimiter Character: |

Badge +1

Worked like a charm @Mark Stoakes​ 

One thing though.. somehow the CSV file format adds additional 2 more pair of double quotes to the text string even though i only defined as one pair of double quotes:

Forum5Forum4Believe it is more of a CSV file issue. Is there any workaround to only show one single pair of double quotes?

Userlevel 1
Badge +21

Worked like a charm @Mark Stoakes​ 

One thing though.. somehow the CSV file format adds additional 2 more pair of double quotes to the text string even though i only defined as one pair of double quotes:

Forum5Forum4Believe it is more of a CSV file issue. Is there any workaround to only show one single pair of double quotes?

I suspect you've got qualify field values set to "As needed", values with quotes will then get additional quotes added.

If you change this value to "No" you won't get the additional quotes

image

Badge +1

@ebygomm​  Thank you that worked!

Reply