Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] -READ with comma delimited & variable length source
Go
New
Search
Notify
Tools
Reply
  
[CLOSED] -READ with comma delimited & variable length source
 Login/Join
 
Silver Member
posted
I have a file that looks like this:
/media/rackspace/db2/clients/Jones/2011/2011-10/2011-10-01/852/ISA_006940860_000003234.edi,852,20110925,20111001,006940860,4014677150,16747,4
/media/rackspace/db2/clients/Jones/2011/2011-10/2011-10-01/852/ISA_014492501_400001168.edi,852,20110925,20111001,014492501,4014677150,40474,2

I have the following code:

FILEDEF INP DISK C:\CLIENTS\CLIENTS\EDILIST.CSV

-READ INP &DIR, &FTYPE, &S_DATE, &E_DATE, &TPID, &MFG, &SIZE, &COUNT
-IF &IORETURN NE 0 THEN GOTO DONE;
-TYPE &DIR; &FTYPE; &E_DATE
-SET &CTR= &CTR+1;
-IF &CTR LT 3 THEN GOTO LOOP;
-EXIT

-DONE

Here is the output this routine produces:

/; med; pace/db2
/; med; pace/db2


If I don't create DEFAULT or SET values for the variables in the -READ, the procedure failes. If I define the variables, the date returned matches the lenght of the variables I set up as the default. If I uset .Axx. syntax to define the langth, I get the results that match my format.

What I need is to read each item between the commas fully, so I can manipulate the results.

Running Windows vers 773

This message has been edited. Last edited by: Kerry,


Steve
 
Posts: 44 | Location: New York City | Registered: May 23, 2004Reply With QuoteReport This Post
Expert
posted Hide Post
set up 1 variable, with a specified length of blanks equal to the largest expected line in your file
make sure its full of blanks to initialize it, otherwise you're reading adjacent garbage in memory
read your line into that space
-READ INP &BIGTHING
Use the TRUNCATE function then to shrink it down to real size, and then the .LENGTH will work.
then token thru (or posit) to look for commas and set each of your individual variables...
i have a routine somewhere that loops thru a long string, looking for the posit of commas, until posit returns a zero
At each step, i set a REMAINDER string starting with the current posit and going to the end of the string....and then operate on that Remainder...
if you follow what i'm saying, i'll look up that code and give it to you, but it wont be till monday




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Reply With QuoteReport This Post
Silver Member
posted Hide Post
Hi Susan,

I thought of this too, but I am being stubborn. The documentation says that -READ can read from a comma delimited file. I guess I was hoping for too much. If it cannot do the parsing into the various variables, it really cannot read a comma delimited file.

I was thinking of reading in each single line and then using the GETTOK to pick it apart at each comma. Seems to be an overkill too. All of this will take a lot of time, for a very simple and one off process to figure out how to file a full directory's files into appropriate structures.

So, here is the question to IBI: Is the -READ supported for comma delimited files, the way one would expect it, or is it not?


Steve
 
Posts: 44 | Location: New York City | Registered: May 23, 2004Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Steve, the odd lines in your sample output don't seem to be comma-separated but slash-separated.

Is that the way your file looks or is that just a wrapping effect of the content you posted?



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
 
Posts: 1533 | Registered: August 12, 2005Reply With QuoteReport This Post
Expert
posted Hide Post
You can write a master file that will parse the .csv, then you don't have to -read
set pcomma = on
remember that?

but like new jersey says, looks like DFIX with delimiter = /

or..if its both, then the way i sugested is perfect. i had a file i had to read every day from the cashregister vendor (name gratefully forgotten) that had 2 different formats in it...the overall format was comma delimited, but one field inside was a comment field with crlf that had to be parsed ...that was fun...




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Steve,
I copied your data and put it into a sequential file. Then I ran your code with a few small changes:
  
-* File SteveC01.fex
FILEDEF INP DISK focalpoint/stevec01.txt
-RUN
-LOOP
-READ INP,&DIR,&FTYPE,&S_DATE,&E_DATE,&TPID,&MFG,&SIZE,&COUNT
-IF &IORETURN NE 0 THEN GOTO DONE;
-TYPE &DIR; &FTYPE; &E_DATE
-GOTO LOOP
-DONE

Notice:
The comma after -READ INP
No blanks between the &variables

And this is the output I received:
  
 /media/rackspace/db2/clients/Jones/2011/2011-10/2011-10-01/852/ISA_006940860_000003234.edi; 852; 20111001
 /media/rackspace/db2/clients/Jones/2011/2011-10/2011-10-01/852/ISA_014492501_400001168.edi; 852; 20111001


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1936 | Location: Tel Aviv, Israel | Registered: March 23, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
awesome!




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Reply With QuoteReport This Post
Expert
posted Hide Post
I think the commna after the IMP is the trigger to read comma delimited.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.06OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6136 | Location: 33.8688° S, 151.2093° E | Registered: October 31, 2006Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Yes, Waz, you are correct...
And it is in the manual! (mirabile scripsu)


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

 
Posts: 1936 | Location: Tel Aviv, Israel | Registered: March 23, 2006Reply With QuoteReport This Post
Expert
posted Hide Post
quote:
And it is in the manual


Eeker

Who'd a thunk it!


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.06OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Know The Code

 
Posts: 6136 | Location: 33.8688° S, 151.2093° E | Registered: October 31, 2006Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] -READ with comma delimited & variable length source

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.