|
|
|||||||
What I would like to do is the following Open a text file thats csv delminated with two fields "Username","UID" I then want my script to match the KIX @USERNAME variable to the entry in this text file and then load in UID into a variable. Any pointers greatfully recieved . |
||||||||
|
|
|||||||
Yep, should be easy. A push into the right direction? Sure, have a look at ReadLine, While – Loop and Split. A silver platter ready for copy paste without learning anything? Open the spoiler. Warning, Spoiler: |
||||||||
|
|
|||||||
George, While Mart's example might work for your data, CSV data can be complicated by the fact that it can contain any text, including quotes, commas, and spaces. These are used by the delimiting process, so data containing spaces or commas MUST be enclosed in quotes, and data containing quotes must be wrapped in multiple quotes. The CSV() UDF (posted here in UDFs, and the most up-to-date on the Kix UDF Library on my web site) will handle all of these embedded characters. The CSV UDF accepts a single argument - a CSV text string or an array of data, and returns the complementary result - an array or formatted CSV string. Here's some pseudocode: Code: $aData = FileIO("filespec", "R") ; UDF to load a file into an array Dim $aUsers[UBound($aData)] ; create an array of user data records Dim $aUIDs[UBound($aData)] ; create an array of UID records For $I = 0 to UBound($aData) ; process the input file data array $aTmp = CSV($aData[$I]) ; convert CSV string to array ; the output array is 2 dimensional - UserName and UID $aUsers[$I] = $aTmp[0] $aUIDs[$I] = $aTmp[1] Next I used 2 arrays to keep the AScan process simple, but you could use a single 2-dimension array to minimize var use. Glenn |