![]() |
||||||||||||
Go ![]() | New ![]() | Search ![]() | Notify ![]() | Tools ![]() | Reply ![]() | ![]() |
Silver Member |
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 773This message has been edited. Last edited by: Kerry, Steve | ||
|
Expert |
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
| |||||
|
Silver Member |
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 | |||
|
Virtuoso |
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. | |||
|
Expert |
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...
| |||||
|
Virtuoso |
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 | |||
|
Expert |
awesome!
| |||||
|
Expert |
I think the commna after the IMP is the trigger to read comma delimited. Waz...
| |||||||||||||||||||||||||||
|
Virtuoso |
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 | |||
|
Expert |
![]() Who'd a thunk it! Waz...
| |||||||||||||||||||||||||||
|
Powered by Social Strata |
![]() | Please Wait. Your request is being processed... |
|