Export Field Seperator
Brian K. White
brian at aljex.com
Mon Aug 13 10:19:18 PDT 2012
If you intend to import into plain old excel, then why aren't you just
using export word?
export word out = "filename.csv"
that all by itself produces
"aaa","bbb","ccc"
If you have quotes in the data, you can make a gosub that you run on the
dangerous fields to detect and edit the field on the fly, the edit is
simply to double any quotes. unfortunately the simplest code for that
requires reading the old variable one character at a time, and building
a new one. But, you can put it all in a gosub and only call that gosub
on the few fields that are in danger of having quotes in them, and then
on top of that, that gosub can start with a single line to detect if
there are any quotes at all and skip all the work in most cases. So most
of the time the routine will not even be called so it shouldn't slow
down most exports.
then: n=6 ; gosub esq ; out(6)=n
...
then: n=20 ; gosub esq ; out(20)=n
...
then: end
esq: ' escape quotes in N
if: not n co chr("92") ' do nothing unless needed
then: return
if:
then: p(8,.0) = "1" ; ic(1) = "" ; o = ""
then: l(8,.0) = len(n{"")
esql: if:
then: ic = mid(n,p,"1") ; oc = ic
if: asc(ic) eq "92"
then: oc = ic{ic
if:
then: o = o & oc
if: p lt l
then: p = p + "1" ; goto esql
if: ' return the edited N
then: n = o ; return
n is the input and then also overwritten for the output at the end
p is a postion marker within the input n, it walks through from
character 1 to the end of n
ic is a single input character, it has one character from n at a time
oc is a single output character or multi-character replacement
o is the temp new output as it's being built up during the routine
Everything else besides double-quotes, not only commas but even
linefeeds and carriage returns should be fine inside the fields.
--
bkw
On 8/13/2012 11:28 AM, Scott Walker wrote:
> Brian,
>
> Thanks. You know what. I just tested excel and it does not let you specify
> (2) characters as a field separator so I guess I'm stuck using one.
>
> Regards,
>
> Scott
>
>
>> -----Original Message-----
>> From: filepro-list-
>> bounces+scottwalker=ramsystemscorp.com at lists.celestial.com
>> [mailto:filepro-list-
>> bounces+scottwalker=ramsystemscorp.com at lists.celestial.com] On Behalf Of
>> Brian K. White
>> Sent: Monday, August 13, 2012 11:20 AM
>> To: filepro-list at lists.celestial.com
>> Subject: Re: Export Field Seperator
>>
>> This should work:
>>
>> export ascii alias = name r=\n o=| c=|
>>
>> But I haven't tried it.
>>
>> --
>> bkw
>>
>>
>> On 8/12/2012 6:35 PM, Scott Walker wrote:
>>> I'm doing an export ascii.
>>>
>>> Is there an easy way to use two characters as the field separator.
>>>
>>> Specifically I'm trying to use two pipe symbols as the field separator.
>>>
>>> Regards,
>>>
>>> Scott
>>>
>>>
>>> Scott Walker
>>> RAM Systems Corp
>>> (704) 896-6549
>>> Scott.Walker at RAMSystemsCorp.com
>>>
>>> www.RAMSystemsCorp.com
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> Filepro-list mailing list
>>> Filepro-list at lists.celestial.com
>>> Subscribe/Unsubscribe/Subscription Changes
>>> http://mailman.celestial.com/mailman/listinfo/filepro-list
>>>
>>
>> _______________________________________________
>> Filepro-list mailing list
>> Filepro-list at lists.celestial.com
>> Subscribe/Unsubscribe/Subscription Changes
>> http://mailman.celestial.com/mailman/listinfo/filepro-list
>
>
>
More information about the Filepro-list
mailing list