Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Red Red is offline
external usenet poster
 
Posts: 48
Default Alternative to ...For Input As #1

I need to open FileA, read through it line by line, parse the data, and
output line by line to FileB. (Both text files)

I'd usually use

Open FileA For Input As #1
Open FileB For Output As #2
Do While Not EOF(1)
Input #1, F1, F2, F3
...various code...
Print #2, F4, F5, F6
Loop
Close #1
Close #2

This works fine with csv files. However, one of the files I need to parse
is + delimeted. Example:

11+6146348+DOC+997+NEW+20041011+124155+REPRINT+

Is there a simple alternative to the above that will work with +? Or will I
have to use

Line Input #1, textLine

and write code to chop up textLine each loop. The fields in FileA are
variable lengths, and the records are longer than the example shown above.
Any suggestions that will save me a lot of time?

Many TIA,

Red.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Alternative to ...For Input As #1

If you have Excel 2000 or later, you can use the split command to "chop up"
the textline

varr = Split(Textline,"+")

for i = lbound(Varr) to ubound(varr)

Next i

Also look at the join function (it is the reverse of Split). You can built
an output array and then use join to convert it to a delimited string (as
long as your string elements don't contain the delimiter ).

--
Regards,
Tom Ogilvy



"Red" wrote in message
...
I need to open FileA, read through it line by line, parse the data, and
output line by line to FileB. (Both text files)

I'd usually use

Open FileA For Input As #1
Open FileB For Output As #2
Do While Not EOF(1)
Input #1, F1, F2, F3
...various code...
Print #2, F4, F5, F6
Loop
Close #1
Close #2

This works fine with csv files. However, one of the files I need to parse
is + delimeted. Example:

11+6146348+DOC+997+NEW+20041011+124155+REPRINT+

Is there a simple alternative to the above that will work with +? Or will

I
have to use

Line Input #1, textLine

and write code to chop up textLine each loop. The fields in FileA are
variable lengths, and the records are longer than the example shown above.
Any suggestions that will save me a lot of time?

Many TIA,

Red.



  #3   Report Post  
Posted to microsoft.public.excel.programming
Red Red is offline
external usenet poster
 
Posts: 48
Default Alternative to ...For Input As #1

"Tom Ogilvy" wrote:

If you have Excel 2000 or later, you can use the split command to "chop up"
the textline


Perfect.

Also look at the join function (it is the reverse of Split).


Thanks Tom! You've saved me a lot of coding!

Red.


an output array and then use join to convert it to a delimited string (as
long as your string elements don't contain the delimiter ).

--
Regards,
Tom Ogilvy



"Red" wrote in message
...
I need to open FileA, read through it line by line, parse the data, and
output line by line to FileB. (Both text files)

I'd usually use

Open FileA For Input As #1
Open FileB For Output As #2
Do While Not EOF(1)
Input #1, F1, F2, F3
...various code...
Print #2, F4, F5, F6
Loop
Close #1
Close #2

This works fine with csv files. However, one of the files I need to parse
is + delimeted. Example:

11+6146348+DOC+997+NEW+20041011+124155+REPRINT+

Is there a simple alternative to the above that will work with +? Or will

I
have to use

Line Input #1, textLine

and write code to chop up textLine each loop. The fields in FileA are
variable lengths, and the records are longer than the example shown above.
Any suggestions that will save me a lot of time?

Many TIA,

Red.




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to input pictures automatically based on cell input? bsharp Excel Worksheet Functions 9 May 30th 09 07:16 AM
input in number form is being multiplied by 1000 when i input. jweinograd Excel Discussion (Misc queries) 4 April 16th 07 11:18 PM
Have user input converted to uppercase in same cell as input? Shannonn New Users to Excel 1 June 20th 06 03:19 AM
How do I add input data in the input ranges in drop down boxes. oil_driller Excel Discussion (Misc queries) 1 November 9th 05 10:31 PM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"