Computing.Net > Forums > Programming > VB Script to remomve CR and LF frm a CSV file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VB Script to remomve CR and LF frm a CSV file

Reply to Message Icon

Name: vibhutidevatraj
Date: May 11, 2009 at 00:22:51 Pacific
OS: Windows XP
Subcategory: General
Comment:

Hi I tried wirting a VB Script like this..


<Code>
Const ForReading = 1
Const ForWriting = 2

strFileName = "HRD.csv"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(strFileName, ForReading)

strText = objFile.ReadAll
objFile.Close

strNewText = Replace(strText, vbCr, "$$$$")
'strNewText = Replace(strNewText, "$$$$", vbCrLf)

Set objFile = objFSO.OpenTextFile(strFileName, ForWriting)
objFile.WriteLine strNewText
objFile.Close
<Code/>
This is removing the CRs but also LF. Converting all the records into one single record. I know im close to resolving this issue..but im missing something..

I believe it can be resolved if i can write a VBscript with thee following logic.


1. Open the File.
2. Read the file line by line.
3. For each line identify each character.
4. Check if that character is Double Quotes(")
5. If its Double Quotes then
6. Check for each charcter if its a CR or LF
7. If its Double Quote then exit this loop.
8. Repeat the Step 5 to 7 until you reach the EOF.
9. Save the Modified File
10. Close the File
Is this logic implemetable?




Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Compile A List of Text, H... Need help in creating mul...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB Script to remomve CR and LF frm a CSV file

VB script to put time and date on www.computing.net/answers/programming/vb-script-to-put-time-and-date-on/18241.html

VB script to change favorites path www.computing.net/answers/programming/vb-script-to-change-favorites-path/13780.html

using a vbs script to add reg value www.computing.net/answers/programming/using-a-vbs-script-to-add-reg-value/15420.html