Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating Records from a .CSV

Status
Not open for further replies.

Varmit57

IS-IT--Management
Mar 15, 2007
56
US
I'm just starting out in Progress and have been handed job that that I'm not having much luck with.

I have a .CSV file with Vendor Numbers and Days in them that need to be updated in our system.

The .CSV file that is formated like:

123456,T
234567,F

it has about 600 records like that.


I need to have it find the Vendor# and change the day on each record to match what is in the .CSV file.

Can someone give me some code to get me started?

Everything that I have tried is erroring out.

Thanks for any help.
 
Make sure your csv file has a carriage return after the last line of data. Then fiddle with this (untested) code snippet below.
Code:
DEFINE VARIABLE cText AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
DEFINE VARIABLE iVendor AS INTEGER NO-UNDO.
DEFINE VARIABLE cDay AS CHARACTER NO-UNDO.

INPUT FROM myFileName NO-ECHO.

REPEAT:
    IMPORT UNFORMATTED cText.

    DO iCount = 1 TO NUM-ENTRIES(cText,','):
        ASSIGN iVendor = INTEGER(ENTRY(1,cText,',')) NO-ERROR.
        ASSIGN cDay = ENTRY(2,cText,',').

        /* Do more stuff as required */
    END.
END.

INPUT CLOSE.
That should get you started.

Cheers, Mike.
 
Here's another approach:

Code:
define temp-table t-vendor
     field t-ven-num as character
     field t-day as character.

input from YourFileName no-echo.
repeat:
   create t-vendor.
   import delimiter ","
       t-vendor.t-ven-num
       t-vendor.t-day.
end.
input close.

for each t-vendor:
     /*  if your vendor.ven-num is not a character field,
         adjust as necessary */
    find vendor where vendor.ven-num = t-vendor.t-ven-num
       no-error.
    if available vendor then do:
           vendor.day = t-vendor.t-day.
    end.
    else do:
         /* this displays a message for each vendor not
            found */
         message "VENDOR NOT FOUND " t-vendor.t-ven-num
         view-as alert-box.
    end.
end.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top