Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to copy a txt file starting from a specific row to another txt file?

Status
Not open for further replies.

kdjonesmtb2

Technical User
Nov 19, 2012
93
0
0
US
Hello,

I have script that creates X12 834 Individual Enrollment trx for Health care

Each file creates a Header rows that I want to ignore when I combine the files into a single file

Only the 1st file should have the header. For example 100 separate files that were created,

I want to combine files 2-100 into file #1

If I want to only select the populated rows in files 2-100 and append them to file #1; starting with row 2 in each of the files(2-100) what is best way to only select the rows in each txt file (the txt files have 67 rows - (carriage returns were used when creating the files)

File name - QTPTest1.x12

Here is an example of code that already appends the existing file to add rows




'Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set fso=createobject("Scripting.FileSystemObject")
Set qfile1 = fso_OpenTextFile("\\ikanas267\Documents\kgittensjones\My Documents\QTP 834\Text files\qtptest" & cstr(row)& ".x12", ForAppending,True)



qfile1.Write(File_Header_SE)

qfile1.Write((DataTable.Value("Common_Delimiter",dtLocalSheet)))

qfile1.Write(Result50) ' calculated number of segments

qfile1.Write((DataTable.Value("Common_Delimiter",dtLocalSheet)))


qfile1.Write(SE02_Transaction_Set_Control_Number)



qfile1.Write((DataTable.Value("Tilde",dtLocalSheet))) & vbcrlf



'GE*1*2013~
'
'
'File_Header_GE
'GE01_Number_of_Transaction_Sets_Included
'GE02_Group_Control_Number


qfile1.Write(File_Header_GE)

qfile1.Write((DataTable.Value("Common_Delimiter",dtLocalSheet)))

qfile1.Write(GE01_Number_of_Transaction_Sets_Included) ' calculated number of segments

qfile1.Write((DataTable.Value("Common_Delimiter",dtLocalSheet)))


qfile1.Write(GE02_Group_Control_Number)


qfile1.Write((DataTable.Value("Tilde",dtLocalSheet))) & vbcrlf
'
'
'File_Header_IEA
'IEA01_Number_of_Included_Functional_Groups


qfile1.Write(File_Header_IEA)

qfile1.Write((DataTable.Value("Common_Delimiter",dtLocalSheet)))

qfile1.Write(IEA01_Number_of_Included_Functional_Groups) ' calculated number of segments

qfile1.Write((DataTable.Value("Common_Delimiter",dtLocalSheet)))

qfile1.Write((DataTable.Value("ISA13_I12_Interchange_Control_Number",dtGlobalSheet)))

qfile1.Write((DataTable.Value("Tilde",dtLocalSheet))) & vbcrlf



'qfile1.Close

objworkbook.close 'Closes the Excel workbook each time a test case is incremented in the Global DataTable
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top