[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: EL Coding: How to write a double-quote character, ", to a file


  • To: <omega-list@xxxxxxxxxx>
  • Subject: Re: EL Coding: How to write a double-quote character, ", to a file
  • From: "Peter B. Nelson" <peter@xxxxxxxxxxxxxxx>
  • Date: Fri, 18 Jan 2002 17:06:15 -0800
  • In-reply-to: <000201c1a073$377481b0$6401a8c0@xxxxxxxxxxx>

PureBytes Links

Trading Reference Links

Fellow EL Coders,
    There are countless reasons one might want to print or save a
double-quote character.  I'm still looking for the way.  Allow me to
illustrate one practical problem:

    I'm creating a .CSV file to import into Excel.  One of the fields I
would like to import contains a function with comma-separated values.  The
commas in the function will be interpreted as separate fields.  FYI, the use
of a double-quote around a field will escape embedded commas.  Two adjacent
double-quotes is converted to one double-quote.

consider a file called X.CSV, with contents like this...

    tradeNum,gain,standardDev,gainToStandardDev

001,010,"=STDEV(INDIRECT(""C[-1]"",FALSE))","=(INDIRECT(""RC[-2]"",FALSE))/(
INDIRECT(""RC[-1]"",FALSE))"

002,020,"=STDEV(INDIRECT(""C[-1]"",FALSE))","=(INDIRECT(""RC[-2]"",FALSE))/(
INDIRECT(""RC[-1]"",FALSE))"

003,018,"=STDEV(INDIRECT(""C[-1]"",FALSE))","=(INDIRECT(""RC[-2]"",FALSE))/(
INDIRECT(""RC[-1]"",FALSE))"

when imported into Excel, it will produce this spreadsheet...

    tradeNum    gain    standardDev    gainToStandardDev
    1    10    5.29    1.89
    2    20    5.29    3.78
    3    18    5.29    3.40

    If you stop to consider the implications, I think you'll agree with me
that this effect is very darn handy.  It allows me to create an entire
spreadsheet from within EL code, formulas and all.  The use of indirect
references means I do not have to keep track of column names.

    FYI, when in cell C1, this function "=STDEV(INDIRECT(""C[-1]"",FALSE))"
is equivalent to "=STDEV(B:B)".  And, when in cell D1, this function
"=(INDIRECT(""RC[-2]"",FALSE))/(INDIRECT(""RC[-1]"",FALSE))" is equivalent
to "=B1/D1"

    One workaround is to tell Excel to use R1C1 style references by default
(Tools/Options/General/R1C1Style).  If I do that, then it isn't necessary to
use the indirect() function.  But I don't like R1C1 style.

    In any case, the REAL problem is that I haven't found a way to represent
a double-quote character in EasyLanguage.  So... if anyone knows a trick, it
sounds like quite a few of us would appreciate it.

Best Regards,
Peter Nelson


----- Original Message -----
From: "Fred Tonetti" <fctonetti@xxxxxxxxx>
Bob/Peter,

I'd like to hear why you guys think this is a necessity ? ...

-----Original Message-----
From: Bob Hunt [mailto:RHunt@xxxxxxxxxxxxxxx]

Peter,

I'd love to hear a solution for this too. ...

-----Original Message-----
"Peter B. Nelson" wrote:
>
> Fellow EL Coders,
>     Does anyone know how to get a double-quote character, ",  into a
string using EasyLanguage?  ...