Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > microsoft.public.scripting.vbscript > #11542

Need a script that Reads each line of a file stores each line into two separate arrays based on the first character of each line.

Newsgroups microsoft.public.scripting.vbscript
Date 2017-02-09 08:55 -0800
Message-ID <5a6e94c2-e0f6-4243-bb77-1538fc01a1fc@googlegroups.com> (permalink)
Subject Need a script that Reads each line of a file stores each line into two separate arrays based on the first character of each line.
From "Jamn .playit" <hbrizzle@gmail.com>

Show all headers | View raw


I do not have to script very often and as such I was wondering anyone could provide some base syntax for a simple script I need to create.

I have a file that will either start with a '1' or a '2' as the first character of each line.

I need to read the file then put each line that starts with '1' in an array and each that starts with '2' into another. Finally simply write each array into a separate file. 

I was using something similar in another script but it has been so long since I had to really code I have forgotten a lot and kind of need this in a hurry, any help would be appreciated. Is it as simple as just using a get left = x?

While expfile.AtEndOfStream = False

		
		expreadline = expfile.readline
		'make sure we don't read any blank lines into the array
		If instr(expreadline,"") > 0 then 
			<this is where i need some syntax>


		
			exparray(counter) = expreadline
			'exparray2(counter) = expreadline2
			'make sure we don't read past the end of our data
				If expfile.AtEndOfStream = False then
					
					counter = counter + 1
					ReDim Preserve exparray(counter)
					Redim Preserve exparray2(counter)
							
				End If

Back to microsoft.public.scripting.vbscript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Need a script that Reads each line of a file stores each line into two separate arrays based on the first character of each line. "Jamn .playit" <hbrizzle@gmail.com> - 2017-02-09 08:55 -0800
  Re: Need a script that Reads each line of a file stores each line intotwo separate arrays based on the first character of each line. "R.Wieser" <address@not.available> - 2017-02-09 18:22 +0100
  Re: Need a script that Reads each line of a file stores each line into two separate arrays based on the first character of each line. "Jamn .playit" <hbrizzle@gmail.com> - 2017-02-09 12:48 -0800
    Re: Need a script that Reads each line of a file stores each lineinto two separate arrays based on the first character of each line. "R.Wieser" <address@not.available> - 2017-02-10 08:53 +0100

csiph-web