1

I am writing a report in SQR which produces a CSV output file. While testing, I ran into an instance where the following string is used in one of my fields:

TABLE - 210" X 60" X 29", OAK,

I currently have double quotes surrounding the string. When I use this method, the output produced is this:

Col 1 |Col 2|Col 3

TABLE - 210 X 60" X 29" | OAK | ,

Obviously, the entire line should fit in the first column.

I understand that it's possible to use other delimiters, but would prefer to keep a comma delimiter. Does anyone know of a way to address this issue?

Here is a simplified version of current code:

Let $asset_descr = '"' || &dep_asset.descr || '"'
Let $string = $asset_descr
Write 1 from $string 
Community
  • 1
  • 1
friedpikmin
  • 31
  • 1
  • 7
  • I wish I had a better answer for you, but because the comma is recognized by Excel as a delimiter, you can't have it in your string. Personally, I like to use the Tab delimiter in Excel and write it with CHR(9). It tends to open much cleaner in Excel. However, your only other option is to convert the comma in your string to something else which is a pain in the neck - you could change it to a semi-colon for instance – cardmagik Aug 12 '13 at 23:06
  • 1
    Talked with my manager concerning changing the delimiter, but it looks that's not a viable option :-(. Thanks for your input though. I was able to figure out a solution. – friedpikmin Aug 14 '13 at 20:06

1 Answers1

2

I was able to finally solve this after A LOT of searching and testing. In order to fix this, I simply replaced each double-quote with two double-quotes. Having two double-quotes treats the double-quote as an 'escape value'... which I guess means that the double-quote is not treated like a closed quote.

This might be a SQR specific solution.

Simplified code solution:

Let $asset_descr = '"' || Replace(&dep_asset.descr, '"', '""') || '"'
Let $string = $asset_descr
Write 1 from $string 
friedpikmin
  • 31
  • 1
  • 7