Loop through fields in an import file?
Richard Kreiss
rkreiss at gccconsulting.net
Wed Feb 9 07:04:35 PST 2011
> -----Original Message-----
> From: filepro-list-bounces+rkreiss=verizon.net at lists.celestial.com
> [mailto:filepro-list-bounces+rkreiss=verizon.net at lists.celestial.com] On
> Behalf Of Mike Schwartz
> Sent: Wednesday, February 09, 2011 9:25 AM
> To: filePro mailing List
> Subject: Loop through fields in an import file?
>
> Using filePro 5.0.14 on Linux, I am trying to import a pipe-delimited
text file
> that has 331 fields in it. I'm writing the data into a filePro file that
has 331
> fields that are laid out exactly like the import file.
>
>
>
> import ascii infile = (@pm) f=| r =\n
>
>
>
> lookup ofile = cust2 r=free -n
>
>
>
> I'd prefer not to write 331 "ofile(1)=infile(1)" style statements,
but I can't
> think of a way to write a loop that will loop 331 times to write all the
import
> fields to the output file.
>
>
>
> I declared fcount(3,.0) = "1" and then wrote a loop that included
> ofile(fcount)=infile(fcount), but filePro gave me a syntax error on that,
> pointing to the "f" in infile(fcount).
>
>
>
> I thought about importing each data record as one long string
(ignoring the
> pipes) and then parsing the string for pipes, but that's a lot of extra
work.
>
>
>
> Or, instead of using "import", I could also "open" the file and use
readline
> to process the data, but I would still have to parse for the pipes.
>
>
>
>
> However, before I sit down and write a lot of complex code, is there
some
> simple 1-liner method to loop through and move these 331 fields into the
> output file?
>
>
>
> Thanks!
>
>
>
> Mike Schwartz
I was programming an export to a csv file for an array with 48 elements. Dim
array(48) One cannot do
Export word comm=w:\ccsv_files\foobar.csv
loop:ct le "48" Comm(ct)=array[ct];ct=ct+"1";GOTO loop
This would have made programming this output much easier as my program has 7
separate arrays that need to be written out.
What I would suggest is that you create 2 arrays, read in your data to the
first array and then overlay the second array to your lookup file and use
the above method to post in the data.
I dont think there is an easy way to do this.
Richard Kreiss
GCC Consulting
rkreiss at gccconsulting.net
More information about the Filepro-list
mailing list