Advertisement

07.24.2008 at 09:54AM PDT, ID: 23592815
[x]
Attachment Details

Parse text file to 512 bytes per record using VBScript

Asked by imranasif17 in VB Script

Tags: Microsoft

Hello Experts:

I have a very large text file.  The data in that is very difficult to read.  What I want is parse the text file such that there is 512 bytes per record (line) and write it in a different output text file.

I have this code which will do it almost.  But there is one problem within this loop,
while len(strChunk)>512
            objW.WriteLine(Left(strChunk, 512))
            strChunk=Mid(strChunk,513)
wend

If the record is less than or equal to 512 maybe it is not doing anything.

Thanks in advance.
Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
dim objFSO: set objFSO=CreateObject("Scripting.FileSystemObject")
dim objR, objW
dim strLine, strChunk
'Text file you are using
set objR=objFSO.OpenTextFile("d:\DRAM Investigation Project\REQINFO.txt",1)
'Text file that will be created
set objW=objFSO.CreateTextFile("d:\DRAM Investigation Project\target.txt",true)
 
strChunk=""
while not objR.AtEndOfStream
	strLine=objR.ReadLine
	strChunk=strChunk & strLine
	while len(strChunk)>512
		objW.WriteLine(Left(strChunk, 512))
		strChunk=Mid(strChunk,513)
	wend
wend
' Write last chunk
objW.WriteLine strChunk
objR.Close
objW.Close
 
Keywords: Parse text file to 512 bytes per recor…
 
Loading Advertisement...
 
[+][-]07.24.2008 at 10:48AM PDT, ID: 22081690

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: VB Script
Tags: Microsoft
Sign Up Now!
Solution Provided By: Shift-3
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.24.2008 at 10:56AM PDT, ID: 22081760

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 11:11AM PDT, ID: 22081890

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 11:13AM PDT, ID: 22081913

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 11:23AM PDT, ID: 22082009

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 12:06PM PDT, ID: 22082435

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 01:12PM PDT, ID: 22083065

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 02:26PM PDT, ID: 22083693

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 02:33PM PDT, ID: 22083742

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628