import of csv
Richard D. Williams
richard at appgrp.net
Mon Dec 4 07:18:08 PST 2017
James,
I think you are being limited by the different number of columns in each
spreadsheet type.
Let's assume the max number of columns is 26.
Dim cols(26):ha, note there is no field edit on dummy field.
In your import when you read your first row you can determine which file
type you are dealing with by
setting zz(1)="1" or zz="2" etc..
Once zz is set, simply goto read1 or read2 or read3 etc..
assume read1 has 10 fields, so
ha=""{inf(1);hb=""{inf(2);hc=""{inf(3);hd=""{inf(4);he=""{inf(5);hf=""{inf(6);hg=""{inf(7);hh=""{inf(8);hi=""{inf(9);hj=""{inf(10);goto
wrt1
And simply follow this pattern for all file types.
Hope this helps,
Richard
On 12/3/2017 11:33 AM, James Flanagan via Filepro-list wrote:
> Filepro 5.7.00.0D94
> FreeBSD
>
> I am trying to write an import routine of csv files where the columns will not be consistent each time. instead, the header row will determine which column contains which value. this will become part of a daily routine import, but there will be no way for me to control the column assignments for each file.
>
> is there any way to refer to the field number of the import with a variable instead of a static number? Thank you very much,
>
> file 1:
> first name,last name,…
> Mike,Jones,…
>
> file 2
> phone number, city, last name,…
> 555-555-1212,Atlanta,Jones,...
>
>
> ::declare local cnt(6,.0):
> ::':
> ::cnt="1":
> ::fn="/tmp/transfer/"{@pm:
> loop::':
> ::import ascii inf=(fn) r=\n f=~:
> :cnt eq "1":po="1";goto get_poc:
> :not inf:delete;exit:
> ::lookup customer r=free -e:
> ::customer(1)=inf(po):
> ::close customer:
> ::cnt=cnt+”1"
> ::goto loop:
> ::':
> get_poc::':
> :inf(po) co “last name":goto loop:
> ::po=po+"1":
> ::goto get_poc:
> ::':
>
> inf(po) co “last name"
> ^
> Process contains a syntax error at position indicated.
>
>
>
>
>
>
> James Flanagan
> Flantec.com <http://flantec.com/>
>
> email: James at Flantec.com <mailto:James at Flantec.com>
> mobile: 760-458-8498
> home: 219-221-6219
> text: 7604588498 at txt.att.net <mailto:7604588498 at txt.att.net>
>
> aim: Flantec
> oovoo: Flantec
> Skype: Flantec
> ichat: Flantec at mac.com <mailto:Flantec at mac.com>
>
> home: 1901 Cidermill Road
> Michigan City, IN 46360
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://mailman.celestial.com/pipermail/filepro-list/attachments/20171203/e07cda01/attachment.html>
> _______________________________________________
> Filepro-list mailing list
> Filepro-list at lists.celestial.com
> Subscribe/Unsubscribe/Subscription Changes
> http://mailman.celestial.com/mailman/listinfo/filepro-list
>
>
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com
More information about the Filepro-list
mailing list