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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple changes CMS Scripting and .csv file

Status
Not open for further replies.

deefish

Technical User
Nov 10, 2008
4
US
(I think I posted this in the wrong place first...so I apologize for the double posting!)

I am trying to set up a .csv file that will contain Agent Skill changes that can be invoked by a CMS script. My problem is my limitation in knowledge of vbscripting.

Here's our concept: The agent IDs/Skills are in an Access db. A mgr selects the agents to be reset/changed. It creates a .csv file, one line per agent.

Can someone please help us with this script? We need to read one line, set the array/variables, and then loop back to the next line until the file is done. Any help would be greatly appreciated!

TEST.csv looks like this:
Agent ID,SK1,Lvl1,Reserve1,SK2,Lvl2,Reserve2....etc.


'LANGUAGE=ENU
'SERVERNAME=10.1.xxx.xx
Public Sub Main()

i = 0 'loop value
Dim sString 'Temporary string to parse *.csv data
Dim vArray 'define array. All data is read into this from test.csv Array
Dim fs, f 'define filesystem stuff for read


'Reads file one line at a time into vArray array
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("C:\temp\test.csv", 1)
sString = f.ReadLine & ","
Do While f.AtEndOfStream <> True
sString = sString & f.ReadLine & ","
Loop 'keep reading in data until EOF hit.
f.Close 'close test.csv file
Set f = Nothing 'clear f and fs
Set fs = Nothing

vArray = Split(sString, ",")
vArraySize = UBound(vArray) + 1 'Determine the size vArray


'## cvs_cmd_begin
'## ID = 8000
'## Description = "Acd Administration, Change Agent Skills"
'## Parameters.Add "Acd Administration","SubSystem"
'## Parameters.Add "Change Agent Skills 5510000 - Doe, Jane","FormName"
'## Parameters.Add "-1","DummyType"
'## Parameters.Add "-1","DummyAcd"
'## Parameters.Add "1","Action"
'## Parameters.Add "1","SetSk_Acd"
'## Parameters.Add "5510000","SetSk_AgentID"
'## Parameters.Add "1","SetSk_CallHandPref"
'## Parameters.Add "0","SetSk_DirectSkill"
'## Parameters.Add "0","SetSk_DirectFirst"
'## Parameters.Add "0","SetSk_ServiceObjective"
'## Parameters.Add "2","SetSk_NumofSkills"
'## Parameters.Add "14","BeginSetSkills"
'## Parameters.Add "905",""
'## Parameters.Add "1",""
'## Parameters.Add "0",""
'## Parameters.Add "333",""
'## Parameters.Add "3",""
'## Parameters.Add "0",""
'## Parameters.Add "","SetSk_Warning"


i = 0 'Reset counter

Do While i < vArraySize - 1
On Error Resume Next

set AgMngObj = cvsSrv.AgentMgmt
ReDim SetArr (2,3)
SetArr(1,1)= 905
SetArr(1,2)= 1
SetArr(1,3)= 0
SetArr(2,1)= 333
SetArr(2,2)= 4
SetArr(2,3)= 0


AgMngObj.AcdStartUp -1, "", cvsSrv.ServerKey, -1
AgMngObj.OleAgentSetSkill 1, "5510000",1, 0,0, 0, 2,SetArr, ""

'## cvs_cmd_end

End Sub
 
it is not really clear what you want to do here. But if you are looking for a simple way to read the CSV and assign variables to each element and then do SOMETHING with that data, here is the basic format of what you need.

Code:
Const ForReading = 1[green]
'Create the file system object[/green]
Set oFSO = CreateObject("Scripting.FileSystemObject")[green]
'open the data file[/green]
Set oTextStream = oFSO.OpenTextFile(C:\temp\test.csv", ForReading)[green]
'make an array from the data file[/green]
CSVArray = Split(oTextStream.ReadAll, vbNewLine)[green]
'close the data file[/green]
oTextStream.Close[green]
'Loop through the records[/green]
For Each AgentLine In CSVArray[green]
	'Now looping through each agent line[/green]
	AgentArray = Split(AgentLine,",")
	Agent ID = AgentArray(0)
	SK1 = AgentArray(1)
	Lvl1 = AgentArray(2)
	Reserve1 = AgentArray(3)
	SK2 = AgentArray(4)
	Lvl2 = AgentArray(5)
	Reserve2 = AgentArray(6)
	[green]
	'Put worker code below this line to do whatever you need with the above variables

        'End Worker Process Section
[/green]
Next

I hope you find this post helpful.

Regards,

Mark

Check out my scripting solutions at
Work SMARTER not HARDER. The Spider's Parlor's Admin Script Pack is a collection of Administrative scripts designed to make IT Administration easier! Save time, get more work done, get the Admin Script Pack.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top