Commas and Quotes embedded in data for PRINT to csv file

Started by steven.rajski, July 09, 2021, 04:57:31 PM

Previous topic - Next topic

steven.rajski

I have data that needs to be in its own column.  Some fields have a leading double quote (") and some have embedded commas.  Here's my print statement:

3100 LET QO$=$22$,SQO$=$22$+$2C$+$3D$+$22$
QO$   is "
SQO$ is ",="


3513 IF MID(SMCROSS$,1,1)=$22$ THEN PRINT (ONEPRICEDUMP)QO$,SMPRC$,"="+CQO$,SMC
3513:ROSS$,SQO$,DUPRESIND$,SQO$, ELSE PRINT (ONEPRICEDUMP)QO$,SMPRC$,SQO$,SMCRO
3513:SS$,SQO$,DUPRESIND$,SQO$,

My goal is to at least show the data with a leading double quote as it is.





Ken Sproul


I find it helpful to create a function that handles the quoting.

For example:

def fn_str$(local x$)
local a_number,x=num(x$,err=*next); a_number=1
return tbl(a_number or pos($2C22$:x$),x$,"="+$22$+sub(x$,$22$,$2222$)+$22$)
end def


print (channel)fn_str$(string1$),",",str(number1),",",fn_str$(string2$),",",fn_str$(string3$),",",str(number2)

Ken Sproul
DPI Information Service, Inc.
Pivotal Systems LLC

Mike King

Have you looked at using the :[STR(",")] format?

For example:

  a$=QUO+"CAB-MSTR..."
  b$="N"
  c=344.40
  PRINT IOL=theiol
!
theiol:IOLIST a$:[STR(",")],b$:[STR(",")],c:[STR(",")]

Mike King
President - BBSysco Consulting - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

steven.rajski

Thank you for your help.  Your suggestion work beautifully.