Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
StarBoy2000
 
Posts: n/a
Default Import Pipe Delimited File, Parse out certian Fields, create new f

In Excel 2000, how do I take a pipe delimited file, strip out column(field)
6, 10, 11, 21. Then take that data, create a new pipe delimited file, and put
the stripped 4 fields in columns 4,5,6,7 of a 15 column(field) new pipe
delimited file? I want to do this automatically on a file that contains
1000+ records.
  #2   Report Post  
JE McGimpsey
 
Posts: n/a
Default

What goes in columns 1-3 and 8-15 of the new file?


In article ,
"StarBoy2000" wrote:

In Excel 2000, how do I take a pipe delimited file, strip out column(field)
6, 10, 11, 21. Then take that data, create a new pipe delimited file, and put
the stripped 4 fields in columns 4,5,6,7 of a 15 column(field) new pipe
delimited file? I want to do this automatically on a file that contains
1000+ records.

  #3   Report Post  
StarBoy2000
 
Posts: n/a
Default

Those columns will be hardcoded with text or left blank (null). The system
I'm sending the new file to has to receive a 15 column (piped) file.

"JE McGimpsey" wrote:

What goes in columns 1-3 and 8-15 of the new file?


In article ,
"StarBoy2000" wrote:

In Excel 2000, how do I take a pipe delimited file, strip out column(field)
6, 10, 11, 21. Then take that data, create a new pipe delimited file, and put
the stripped 4 fields in columns 4,5,6,7 of a 15 column(field) new pipe
delimited file? I want to do this automatically on a file that contains
1000+ records.


  #4   Report Post  
JE McGimpsey
 
Posts: n/a
Default

One way:

Public Sub PipeFileTransform()
Const sDELIMITER As String = "|"
Dim vArr As Variant
Dim nFileIn As Long
Dim nFileOut As Long
Dim sPre As String
Dim sPost As String
Dim sInput As String
Dim sOutput As String

sPre = String(3, sDELIMITER)
sPost = String(8, sDELIMITER)

nFileIn = FreeFile
Open "Test1.txt" For Input As #nFileIn
nFileOut = FreeFile
Open "Test2.txt" For Output As #nFileOut
Do While Not EOF(1)
Line Input #1, sInput
vArr = Split(sInput, "|")
sOutput = sPre & vArr(5) & sDELIMITER & vArr(9) & _
sDELIMITER & vArr(10) & sDELIMITER & _
vArr(20) & sPost
Print #2, sOutput
Loop
Close #nFileIn
Close #nFileOut
End Sub

Adjust sPre and sPost as desired. Note that Split() is a VBA6 function.
If you need this to work with WinXL97 or MacXL, you'll need to roll your
own Split function.



In article ,
"StarBoy2000" wrote:

Those columns will be hardcoded with text or left blank (null). The system
I'm sending the new file to has to receive a 15 column (piped) file.

  #5   Report Post  
JE McGimpsey
 
Posts: n/a
Default

It doesn't make any difference in this case, but for foolish
consistency, the line below should have been:

vArr = Split(sInput, sDELIMITER)



In article ,
JE McGimpsey wrote:


vArr = Split(sInput, "|")

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
import external data from changing file name nathan Excel Worksheet Functions 2 April 6th 05 04:39 PM
save excel file from a table delimited file (.txt) using macros sedamfo New Users to Excel 1 February 15th 05 04:19 AM
I have a Comma delimited text file how do I import in to excel an. trevord Excel Discussion (Misc queries) 1 February 3rd 05 11:41 PM
Weekly Transaction Processing Ralph Howarth Excel Worksheet Functions 4 January 19th 05 05:37 AM
Import file names into cells craigwojo Excel Worksheet Functions 2 November 2nd 04 11:19 PM


All times are GMT +1. The time now is 08:33 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"