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

add special character to a comma delimited file

Status
Not open for further replies.

lovettj

Programmer
May 22, 2007
10
US
Hi,

I am trying to add a special character single quotes around each text file that is in a comma delimited file. I need to automate this process so therefore I decided to use VBScript. Here an example of the input and the output that i Need.

33,Gary,Louis,Becerra,,Supervision (input)

'33','Gary','Louis','Becerra','','Supervision' (output)

Thanks in advance.
 
taupirho

I am trying to unstand the split function in VBscript that's as far as I have gotten.

Any help will be very appreciative.
 




Show us how you used the split function.

what problems are you having?

Skip,

[glasses] [red][/red]
[tongue]
 
A simpler way than the Split/Join one:
Code:
strInput="33,Gary,Louis,Becerra,,Supervision"
MsgBox "'" & Replace(strInput,",","','") & "'"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
i think this is what you need:
Code:
each_line = "33,Gary,Louis,Becerra,,Supervision" 

each_item = split(each_line, ",") 
' you have to repeat this loop for each line of the file
for i = 0 to ubound(each_item)  
    each_item(i) = chr(39) & each_item(i) & chr(39)        
next

new_line = join(each_item, ",")

msgbox new_line
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top