Caleb_D
(Caleb D)
1
I’m trying to output variables to a CSV file with double quotes surrounding each value.
Desired Result:

This is my sequence where I try 2 different methods:
in_EmpID = “123”
in_EmpName = “John Doe”
METHOD 1:
vEmpID = Chr(34)+in_EmpID+Chr(34)
vEmpName = Chr(34)+in_EmpName+Chr(34)
METHOD 2:
vEmpID = “”“”+in_EmpID+“”“”
vEmpName = “”“”+in_EmpName+“”“”
Below is the Actual Output in both Excel and Notepad++. The first row corresponds to Method 1 and the 2nd to Method 2.
When I view the CSV via Excel, both methods seem to work as desired:

However, when I view the CSV via Notepad (which is where I need it to be correct), it looks like this:

Why is it surrounding the values with 3 double quotes instead of only 1 and how do I correct this?
ppr
(Peter Preuss)
2
we do opening the string with ", same we close
we escape a " with a double "
so " (opening) “” (Escape + Quote = 2) = 3, same for closing
statement is related to the code e.g.

\ is visualizing the escape "
Caleb_D
(Caleb D)
3
So why doesn’t Method 1 work? And do you have a solution?
ppr
(Peter Preuss)
4
there is no string so we do not have to open with ", as we are using the method and concatenating with a variable
Method 2 is as explained above: " for opening “” (escape and quote) " for ending the string = 4
Caleb_D
(Caleb D)
5
So I found where the problem was occurring… seems to be a bug with the Add Data Row activity…
Both methods were working in that the variables were as expected “123” and “John Doe”
But when I went to Add Data Row, the activity was adding the extra double quotes.
Code:
Output:

As a workaround, I just used the Append Line activity.
system
(system)
Closed
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.