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!

VBScript Noob

Status
Not open for further replies.

isbbrg

IS-IT--Management
May 20, 2010
2
US
So im new to vb script and i have no clue where to start. In a nutshell i need to take a CSV manipulate the fields: add move and so on. Then dump it to a fixed length flat file.

I am trying to use a program called textpipe pro that offers some functionality to accomplish what i want but it doesnt quite cut the cheese as far as pre-installed filters. It does however have a VBScript section and a JScript section where you can add your own script and it will run that instead.

CSV Input looks like the following
Field Title
1 Phone
2 Last
3 First
4 Add
5 City
6 State
7 Zip
8 Phone
9 First

Fixed Length Output
Field Title Field Length
1 Call Code(prepopulated with the #9) 9
2 Phone 10
3 Last 35
4 First 15
5 Salutation 4
6 Company 35
7 First 35
8 Addr1 35
9 Addr2 10
10 City 30
11 State 2
12 Zip 5
13 Source 22
14 RecType 5
15 Camp 6
16 ListID 6


Any help would be appreciated maybe and example with 2 or 3 fields and i can figure out the rest i just need something to work off of to get me headed the right direction.

Thanks for the help guys
 
Sorry it is not clear to me what you are trying to do. Can you better explain?

Also, do you have access to Excel? You will be able to better manipulate the data if you can use Excel. Otherwise you have to read in the CSV and dynamically build a new one since you can't edit the existing one on the fly.

I hope that helps.

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.
 
I can manipulate the csv's using a wonderful program called CSVED but what i need to accomplish is taking a CSV and the data withing it and convert it to a fixed length field flat file.
 
You might try support for CSVED then. I can offer solutions for VBscript but not the third party product.

I hope that helps.

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.
 
Below is some VBScript you can use to automate the filter creation process in TextPipe - if you don't want to do it through the user interface:

'The global TextPipe Application object
dim vb_TextPipeApp
'The global TextPipe Filter Window
dim vb_TPWindow

Set vb_TextPipeApp = CreateObject("TextPipe.Application")
Set vb_TPWindow = vb_TextPipeApp.newWindow


TPWindow.startFilters
TPWindow.clearAllFilters
TPWindow.logEnabled = false
TPWindow.logFilename = "textpipe.log"
TPWindow.logAppend = true
TPWindow.logThreshold = 500
TPWindow.inputMode = 1
TPWindow.inputBinaryFiles = 0
TPWindow.inputBinarySampleSize = 100
TPWindow.inputPromptOnEach = false
TPWindow.inputPromptOnReadOnly = false
TPWindow.inputDeleteFiles = false
TPWindow.inputInsideCompressed = true
f1 = TPWindow.addSelectionFilter( 4, 1, 1, 1, 1, true, true, true, 0, "", false )
TPWindow.startSubfilters
f2 = TPWindow.addNumberFilter( 3, 9 )
TPWindow.endSubfilters

f1 = TPWindow.addSelectionFilter( 4, 1, 2, 1, 1, true, true, true, 0, "", false )
TPWindow.startSubfilters
f2 = TPWindow.addNumberFilter( 3, 10 )
TPWindow.endSubfilters

f1 = TPWindow.addSelectionFilter( 4, 1, 3, 1, 1, true, true, true, 0, "", false )
TPWindow.startSubfilters
f2 = TPWindow.addNumberFilter( 3, 35 )
TPWindow.endSubfilters

;more of the above for each field

f1 = TPWindow.addReplaceFilter( ",", "", 4, false, false, false, false, false, false, false, 0 )
f1 = TPWindow.setPerl( 4096, false, false, true, false )
TPWindow.outputMode = 1
TPWindow.outputRetainDate = false
TPWindow.outputTestMode = 2
TPWindow.outputAppend = false
TPWindow.outputOnlyOutputChangedFiles = 1
TPWindow.outputOpenOutputOnCompletion = false
TPWindow.outputExtension = ""
TPWindow.outputFolder = ""
TPWindow.outputRemoveEmpty = false
TPWindow.endFilters


'File List:
TPWindow.clearAllFiles
TPWindow.addFile "", 0, 1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top