![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to edit a text file (remove carriage returns) I have around 68,000 records on a text file +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration /owner =builtin\administrators +File E:\JOHN_BACKUP\SCOPEFOLDER\Eng /owner =builtin\administrators +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration\CARMEN /owner =scope\administrator I would like to change it to: +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration /owner =builtin\administrators +File E:\JOHN_BACKUP\SCOPEFOLDER\Eng /owner =builtin\administrators +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration\CARMEN /owner =scope\administrator I would like to remove all carriage returns, so i can import the text file into and access database Thank you all, Bre-x |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How to edit a text file (remove carriage returns) Try opening the text file with a hex editor, like PSPad in hex view mode, or XVI, both freely available on the internet. Line separators may be a single carriage return character or a single line feed character or a combination of the two. The hex editor should show you whether there is a specific string that comes before and after the line separator you want to remove, and you should be able to build a string in your script to match what you want replaced (something like sTemp = "pretext" & vbCrLf & "posttext"). Then have the script read the entire file into a string and use the Replace function to replace the old PretextLineseparatorPosttext combination with your desired PretextSpaceorwhateverPosttext string. Then write the newstring out to a file. I have successfully used this technique on files as large as 38 megabytes read as one chunk. On large files you may find Textstream.Readall to be significantly slower than Textstream.Read(filesize), and you must use the.Read(chunksize) method if the file contains any Chr(0) characters. -Paul Randall "Bre-x" <cholotron@xxxxxx> wrote in message news:O0ZO9iu2JHA.4744@xxxxxx Quote: >I have around 68,000 records on a text file > > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration > /owner =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Eng > /owner =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration\CARMEN > /owner =scope\administrator > > > I would like to change it to: > > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration /owner > =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Eng /owner =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration\CARMEN /owner > =scope\administrator > > > I would like to remove all carriage returns, so i can import the text file > into and access database > > Thank you all, > > > Bre-x > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How to edit a text file (remove carriage returns) On May 22, 9:22*am, "Bre-x" <cholot...@xxxxxx> wrote: Quote: > I have around 68,000 records on a text file > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration > /owner * * * * * * =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Eng > /owner * * * * * * =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration\CARMEN > /owner * * * * * * =scope\administrator > > I would like to change it to: > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration /owner > =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Eng /owner > =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration\CARMEN /owner > =scope\administrator > > I would like to remove all carriage returns, so i can import the text file > into and access database > > Thank you all, > > Bre-x This might work if the second line is a tab between what you want to split. I am also not sure if you will need to add that space on line 16 of the script. Try it and post the result file and that will help me. Set objFSO = CreateObject("Scripting.FileSystemObject") Set objTextFile = objFSO.OpenTextFile ("old.txt", 1) strText = objTextFile.ReadAll objTextFile.Close arrLines = Split(strText, vbCrLf) Set objTextFile2 = objFSO.OpenTextFile("new.txt", 2, True) i = 1 For Each strLine in arrLines If i mod 2 = 1 Then objTextFile2.Write strLine & Space(1) Else arrsplitline = Split(strLine, vbTab) objTextFile2.Write arrsplitline(0) & vbCrLf & arrsplitline(1) & vbCrLf End If i = i +1 Next |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How to edit a text file (remove carriage returns) Thank guys "Bre-x" <cholotron@xxxxxx> wrote in message news:O0ZO9iu2JHA.4744@xxxxxx Quote: >I have around 68,000 records on a text file > > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration > /owner =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Eng > /owner =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration\CARMEN > /owner =scope\administrator > > > I would like to change it to: > > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration /owner > =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Eng /owner =builtin\administrators > > +File E:\JOHN_BACKUP\SCOPEFOLDER\Administration\CARMEN /owner > =scope\administrator > > > I would like to remove all carriage returns, so i can import the text file > into and access database > > Thank you all, > > > Bre-x > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Text attachments - carriage returns inserted into attachment | Live Mail | |||
| How to remove carriage returns in a text file. | VB Script | |||
| Avoid "carriage return" in text file | PowerShell | |||
| Preserve carriage returns in RichTextBox control | .NET General | |||
| Add-Content and carriage returns | PowerShell | |||