Skip to Content
avatar image
Former Member

script - merge two files into one

Hi ,

I have process which take data from .txt files (file_A.txt, file_B.txt).
I'd like to add option at the end of process which marge above files into one file .txt and add to this file additional column with file name.
I tried to do this in script and cmd commnads but without success.

In windows 'commant prompt' below command works but I can't get the same in BODS.

cd C:\test
for /f %a in ('dir /b file_*.txt') do for /f "tokens=*" %b in (%a) do echo %b,%a
>> C:\test\test2\file_final.txt


Maybe you have idea how can I do it in different way

My BODS - 4.2 SP2

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Jul 05, 2017 at 09:55 AM

    If all files are the same format, define the DS file format for the sources, make sure to include the DI_Filename column in the format definition

    Create a 2nd file format for the output file, with one additional column.

    Build a simple data flow. Use the 1st file format as source in a Query transform, use a wildcard for the file name and map all fields one-to-one. Connect the Query to the 2nd file format and run. The DI_filename column will be populated automatically.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 04, 2017 at 12:41 PM

    does anybody has any idea?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 05, 2017 at 04:26 PM

    Create you DF something like below. In QRY_ADD_SOURCE_NAME_1 and QRY_ADD_SOURCE_NAME add additional column as source name in which put the value of your source. Merge them using merge transform then.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 11, 2017 at 12:49 PM

    Hi,

    thank you for answer - I had idea to built DF which will export data in the last step into one flat file but I thought I can do it in script also. In cmc commands my idea works, in script - probably I missed somewhere " or ' or /
    But thanks for help

    Regards

    Add comment
    10|10000 characters needed characters exceeded