Merging of two text files

HI All,,
I have a text file A with four fields and text file B with two fields. I wanted to club these two text files to a single text file with certain condition and that to be uploaded to a standard table through BDC.
am I clear??
Please suggest me how can I proceed for this.
thanks,
anil.

Hi
If you want to do this using a program
Then use Function Module
GUI_UPLOAD
to load the two text files into two internal tables
say itab1 for one with 4 fields
and itab2 for the one with 2 fields
Then you can join the two tables based on a key between the two into a final internal table with six fields
use the function module GUI_DOWNLOAD to download the internal tab with six fields and you have the final file which you would need to upload for the BDC.
Here also you can use GUI_UPLOAD to load the text file for the BDC program

Similar Messages

  • Compare two text files in Powershell and if a name is found in both files output content from file 2 to a 3rd text file

    Is it possible using PowerShell to compare the contents of two text files line by line and if a line is found output that line to a third text file?
    Lets say hypothetically someone asks us to search a text file named names1.txt and when a name is found in names1.txt we then pair that with the same name in the second text file called names2.txt
    lets say the names shown below are in names1.txt
    Bob
    Mike
    George
    Lets say the names and contents shown below are in names2.txt
    Lisa
    Jordan
    Mike 1112222
    Bob 8675309
    Don
    Joe
    Lets say we want names3.txt to contain the data shown below
    Mike 1112222
    Bob 8675309
    In vbscript I used search and replace commands to get part of the way there like this
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objFile = objFSO.OpenTextFile("testing.txt", ForReading)
    strText = objFile.ReadAll
    objFile.Close
    strNewText = Replace(strText, "Mike ", "Mike 1112222")
    Set objFile = objFSO.OpenTextFile("testing.txt", ForWriting)
    objFile.WriteLine strNewText
    objFile.Close
    That script works great when you know the name you are looking for and the correct values. Lets say someone gives you a list of 1000 employees and says import these names into a list in the correct format and one sheet has the correct names only and
    the other sheet has lots of extra names say 200000 and you only need the 1000 you are looking for in the format from names2.txt.

    Sure,
    Here's a simple one:
    $names1 = "C:\names1.txt"
    $names2 = "C:\names2.txt"
    $names3 = "C:\names3.txt"
    Get-Content $names1 | ForEach-Object {
    $names1_Line = $_
    Get-Content $names2 | Where-Object {$_.Contains($names1_Line)} | Out-File -FilePath $names3 -Append
    This basically just reads $names1 file, line by line, and then read $names2 file line by line as well.
    If the line being evaluated from $names2 file contains the line being evaluated from $names1 file, then the line from $names2 file gets output to $names3 file, appending to what's already there.
    This might need a few more tinkering to get it to perform faster etc depending on your requirements. For example:
    - If either $names1 or $names2 contain a lot of entries (in the region of hundreds) then it will be faster to load the whole content of $names2 into memory rather than opening the file, reading line by line, closing and then doing the same for every single
    line in $names1 (which is how it is currently works)
    - Make sure that your comparison is behaving as expected. The .Contains method always does a case sensitive comparison, this might not be what you are after.
    - You might want to put a condition to ignore blank lines or lines with spaces, else they'll also be brought over to $names3
    Hopefully this will get you started though and ask if you have further questions.
    Fausto

  • Compare two text file

    i am comparing two text file by checking occurance of a line in file 1 by comparing it with each line in file 2(not line by line)
    i have to print in 3rd text file as difference
    please see my progrm and tell me modification required
    package comp.vnet.comparator;
    import java.io.*;
    import comp.vnet.comparator.NewFile;
    class FileComparator {
         public static void main(String[] args) throws IOException{
              String file1,file2,String1,String2;
              BufferedReader br1,br2;
              int fileCount1=0;
              int fileCount2=0;
              br1= new BufferedReader(new InputStreamReader (System.in));
              // File file = new File ("output.txt");
              FileWriter fstream = new FileWriter("out.txt");
              // FileOutputStream fo = new FileOutputStream("E:/Filecomparator/FileComparator/output.txt");
              System.out.println("Enter First file name");
              file1="b.txt";
              //file1=br1.readLine();
              System.out.println("Enter Second file name");
              file2="a.txt";
              //file2=br2.readLine();
              NewFile nf= new NewFile();
              br1=nf.creatingFile(file1);
              br2=nf.creatingFile(file2);
    while ((String1= br1.readLine()) != null) {
         fileCount1++;
    while ((String2= br2.readLine()) != null) {
         fileCount2++;
    System.out.println("fileCount1+ : " + fileCount1);
    System.out.println("fileCount2+ : " + fileCount1);
    br1=nf.creatingFile(file1);
    BufferedWriter out = new BufferedWriter(fstream);
    for(int i=0;i<=fileCount1;i++)
         br2=nf.creatingFile(file2);
         String1=br1.readLine();
         for(int j=0;j<fileCount2;j++)
                   String2=br2.readLine();
                        if ( String1.equals (String2) ) {
                             System.out.println("the line is equal");
                        else{
                        out.write(String1);
                             System.out.println(String1);
    out.close();
    br1.close();
    br2.close();
              }

    thanks alot for that reply
    but there is some error
    pleasse send me a nice reply

  • How to read two text files using the Read from spreadsheet.vi and then plot it

    I need to read two text files using the read from spreadsheet function and then plot these files over time.
    The file with the .res extention is the RMS values (dt and df) and the second file contains the amplitude of a frequency spectrum.
    I really appreciate any help..thanks
    Attachments:
    RMS.txt ‏1 KB
    FREQUENCY.txt ‏1 KB

    From NI Example Finder:
    Write to Text File.vi
    Read from Text File.vi
    Jean-Marc
    LV2009 and LV2013
    Free PDF Report with iTextSharp

  • How to compare content of two text file using StreamTokenizer

    hi....
    i have two text files...containg field like(name,number,scheme) and(number,date,value)... i want to create a third file containg field like (name,number,date,scheme,value) by using these two table. how to create

    I think this code can solve your problem.
    private static final String DELIM = ",";
    * Compile two files.
    * @param file1 String the input file 1
    * @param file2 String the input file 2
    * @param file3 String the output file
    * @throws IOException error in reading/writing
    public void compileFiles(String file1, String file2, String file3) throws
            IOException {
            BufferedReader reader1 = new BufferedReader(new InputStreamReader(
                new FileInputStream(file1)));
            BufferedReader reader2 = new BufferedReader(new InputStreamReader(
                new FileInputStream(file2)));
            BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(
                new FileOutputStream(file3)));
            String line1 = reader1.readLine();
            String line2 = reader2.readLine();
            while (line1 != null && line2 != null) {
                writer.write(compileLines(line1, line2));
                writer.newLine();
                line1 = reader1.readLine();
                line2 = reader2.readLine();
            reader1.close();
            reader2.close();
            writer.close();
        private String compileLines(String line1, String line2) {
            StringTokenizer tok1 = new StringTokenizer(line1, DELIM);
            StringTokenizer tok2 = new StringTokenizer(line2, DELIM);
            String name = tok1.nextToken();
            String number = tok1.nextToken();
            String scheme = tok1.nextToken();
            // ignore number
            tok2.nextToken();
            String date = tok2.nextToken();
            String value = tok2.nextToken();
            StringBuffer buffer = new StringBuffer();
            buffer.append(name);
            buffer.append(DELIM);
            buffer.append(number);
            buffer.append(DELIM);
            buffer.append(date);
            buffer.append(DELIM);
            buffer.append(scheme);
            buffer.append(DELIM);
            buffer.append(value);
            return buffer.toString();
        }

  • Comparing two text files in a UNIX using shell programming

    Hi All,
    Sorry for posting a UNIX shell query on Database forums.
    I want to compare two text files using shell programming. The two text files are actually Business Objects output extracted in a text format. The two output files are not in a tabular format and are no way similar in looking. I want to take one file e.g. file1 as an input file and compare each line of file1 with the other file e.g. file2. During comparison I want to extract the differences found in another file and if possible the similar data as well.
    Below is how the files will look like
    File 1:
    BILL1000000 1111251 122222
    RMG1A2 023425100000000010001 11135 102650111100
    UHL1 *6999999* *454540001* Weekly *000*
    0544424556895PS DATA 01MPS100000/03 MR A A PERTH UTL1234567893106923455053106900000010000005
    File 2:
    AUTO
    APPLICATION=STARTPOINT
    START
    PROCESSING DATE=01012011
    1598301270320099TEST C E 00000031615 123456
    7854301276140499TES P 00000062943 234567
    UHL1 *6999999* *454540001* Weekly *000*
    5569931233333499/123456789 00000013396 345678
    4471931233333499ER K J 00000031835123456789012456789
    33652931233333499E J L 00000034729123456789012567890
    45783123333349921/123456789 00000039080 678901
    1452931233333499T R 00000040678123456789012789012
    59689312333334994/987654321 00000048614 890123
    4112931233333499/987654321 00000060631 901234
    1236931217836899 K S 00000043704 012345
    END
    As you can see above the file are not at all matching except for one record UHL1, but its just an example. As an output I would like to have a third file containing all these records, highlighting the differences, and a fourth file where in only the matched records should get populated.
    Please post any useful scripts related to the above scenario.
    Many Thanks.
    Edited by: 848265 on 06-Apr-2011 04:13

    Hi;
    For your issue i suggest close your thread here as changing thread status to answere and move it to Forum Home » Linux which you can get more quick response
    Regard
    Helios

  • Merge two text files

    Need your help with merging two text source files into single table.  Each text file is single column containing names.  Let's say that file one is list of members in DEPARTMENT A and second file members of DEPARTMENT B.  Text files look
    something as follows:
    Filename: DEPARTMENT_A
    NAME (header)
    Steve
    Joe
    Mary
    Filename: DEPARTMENT_B
    NAME (header)
    Ron
    Joe
    Susie
    Ultimately, I need the resultant table data to look like this:
    NAME     DEPARTMENTS
    Steve     A
    Joe        A, B
    Mary      A 
    Ron        B
    etc.
    I think the solution involves derived columns, pivot, coalesce, but can't figure out how to put them together.  What do you recommend?  Thanks.

    You need a data flow task
    Inside that have two flat file sources connecting to both files. Following that have a derived column task to add department information (A,B). use a union all transform to merge both the inputs and finally use OLEDB destination to dump the result into table
    with two columns Name and Department.
    Then add a execute sql task to do update as below
    UPDATE t
    SET Department = Department + ', B'
    FROM Table t
    WHERE Department = 'A'
    AND EXISTS (SELECT 1
    FROM Table
    WHERE Name = t.Name
    AND Department = 'B'
    DELETE t
    FROM Table t
    WHERE Department = 'B'
    AND EXISTS (SELECT 1
    FROM Table
    WHERE Name = t.Name
    AND Department = 'A, B'
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Can I combine two text files into ine with ZEN

    I have to append a really long character string onto an existing txt file.
    I tried to modify the file in ZEN but the app blows up when it runs. Is
    there a way I could concatenate these two txt files together with ZEN
    instead?

    Another option would be to create two environment variables each holding
    1/2 the string. Then use the Text file section to write the two strings
    to the one file.
    Robin Witkop-Staub wrote:
    > oh - good idea...
    >
    > "Anders Gustafsson" <[email protected]> wrote in message
    > news:[email protected]..
    >> Robin Witkop-Staub,
    >>> I have to append a really long character string onto an existing txt
    >>> file.
    >>> I tried to modify the file in ZEN but the app blows up when it runs. Is
    >>> there a way I could concatenate these two txt files together with ZEN
    >>> instead?
    >>>
    >> Spawn a batchfile that concatenates the files, ie copy file1+file2 file3
    >>
    >> - Anders Gustafsson, Engineer, CNE6, ASE
    >> NSC Volunteer Sysop
    >> Pedago, The Aaland Islands (N60 E20)
    >>
    >> Novell does not monitor these forums officially.
    >> Enhancement requests for all Novell products may be made at
    >> http://support.novell.com/enhancement
    >>
    >> Using VA 5.51 build 315 on Windows 2000 build 2195
    >>
    >
    >
    Craig Wilson
    Novell Product Support Forum Sysop
    Master CNE, MCSE 2003, CCN

  • Write to two text files

    Hello Everyone,
    I would like for my VI to write to two different text files. I have it now where I can write the two different types of data to one text file. When I adjusted it to write to two different files, it makes me open the two files where I would like to save the data but it doesn't record anything.
    Thank you,
    Corina

    Could you please post either an image of your code or the VI itself?  I think that it will be easier to tell what is going on with a visual aid.  Thanks.
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.

  • I want to insert two text files in to oracle.

    Ex :
    text1.txt contains data as
    1 a
    2 b
    3 c
    text2.txt contains data as
    4 d
    5 e
    6 f
    I want to load both text file into oracle as
    1 a 4 d
    2 b 5 e
    3 c 6 f
    for these how to create *.ctl file*

    I wouldn't use SQL*Loader for this.
    Here's an example based on your simplified example, but it should get you going.
    I used an external table, so you can load both files at the same time, by adding the filenames to the location.
    By using the PIVOT technique, you can insert the data in the destination table as desired:
    By the way: I needed some help for that last query:http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:4937250900346222596 ;)
    SQL> drop table destination purge;
    Table dropped.
    SQL> drop table test purge;
    Table dropped.
    -- Create our desination table:
    SQL> create table destination
      2  ( col1 varchar2(1)
      3  , col2 varchar2(1)
      4  , col3 varchar2(1)
      5  , col4 varchar2(1)
      6  );
    Table created.
    -- Instead of using SQL*Loader, we use an external table to query text1.txt and text2.txt at the same time:
    SQL> create table test
      2  ( col1 varchar2(1)
      3  , col2 varchar2(1)
      4  )
      5  organization external
      6  ( type oracle_loader
      7    default directory DATA_PUMP_DIR
      8    access parameters ( records delimited by newline
      9                        fields terminated by ' '
    10                        lrtrim
    11                        missing field values are null
    12                        ( col1 char(1)
    13                        , col2 char(1)
    14                        )
    15                      )
    16      location ('text1.txt'
    17               ,'text2.txt'
    18               )
    19  );
    Table created.
    -- The data belonging to both files:
    SQL> select * from test;
    C C
    1 a
    2 b
    3 c
    4 d
    5 e
    6 f
    6 rows selected.
    -- Now just pivot as desired and insert with a single SQL statement:
    SQL> insert into destination(col1, col2, col3, col4)
      2  select max(c1_1)
      3  ,      max(c2_1)
      4  ,      max(c1_2)
      5  ,      max(c2_2)
      6  from ( select decode( nt, 1, col1 ) c1_1
      7         ,      decode( nt, 1, col2 ) c2_1
      8         ,      decode( nt, 2, col1 ) c1_2
      9         ,      decode( nt, 2, col2 ) c2_2
    10         ,      row_number() over (partition by nt order by col1) rn
    11         from ( select col1
    12                ,      col2
    13                ,      ntile(2) over (order by col1) nt
    14                from t
    15              )
    16       )
    17  group by rn
    18  order by rn;
    3 rows created.
    -- Look ma, we're already done!
    SQL> select * from destination;
    C C C C
    1 a 4 d
    2 b 5 e
    3 c 6 f

  • Compare two text files

    Guys I have two .txt files like the one below
    00001                
    00002
    00003
    00004
    00005
    00006
    Some elements are missing from one to the other one...
    I need to compare these two and find the different elements of each file...
    I been reading the old post but I cant figure anything out of them
    Any ideas???

    Hi Darin,
    I am doing more or less same sort of thing but its between the two folder number of files to be compared and then copying the missing files lets say from folder A to folder B. The first part is not a problem to read the content and then compare them but what I am stuck in is that, I want to see while the VI is running that how much data is being copying and how much is remaining my be in percentage on some status bar or may be time or may be out of 55 files 20 files copyied 35 remaining etc. Can you please guide me through this how to do it any idea. It will be great help.
    Regards,
    Naqqash
    Naqqash

  • Compare two text files for matching data

    HI
    I want to compare data in two separate spreadsheet files and store the matching data in another spreadsheet file.
    like
    1)reading data from two spread sheets
    2)compare the data of fist one with second
    3)writing the matched data to third one.
    I am find difficulty in combining them to sort string bu string
    pls help me in this
    thanks
    jyohti

    hi
    i am implementing the following logic
    1)  textfile1--------->string to array
    2)textfile 2--------->string to array
    3) compare the elements (substring) of one array to other using for loop
    4)append the match to an array every time you find a match betwwen two arrays
    5)wriitng the result in new file
    i am strugulling in with 3) i have finshed 1,2,4and 5 th part
    problelms are with indexing and loop conditions for me...
    anyways i am trying and feeling like i will finish and post that soon....

  • Comparing contents of two text files

    I know that I can copy all contents of the two files into two strings, and then do str1.equals(str2). Any better way to do it?

    What kind of comparison do you want to do?
    - Exact - the files must have the same size, and have the same bytes, like "fc /b" in Windows
    The exact comparison is very easy to do: open the files as FileInputStreams and read both using byte buffers. Compare the byte buffers.
    If you can't open both files at the same time (for instance, one of the files is in a diskette and the other file is in another diskette, and you have only one diskette drive) you could try checking the digest of the files (java.security.MessageDigest). If the digest values match, probably the files are equal. If the digest values don't match, certainly the files are different.
    - Textual - you want to find differences between the files, and pinpoint them, like the "diff" command in Unix, or the "fc" command in Windows.
    Textual comparison is not easy to do (you'll need to keep lists of matching lines, and figure out if some sequence of lines was moved, changed etc.); but you can find the source code for it in several places.

  • Match a data string in each record of two text files

    What is the easiest way to match a string of characters in each record of File1.txt with the same string in File2.txt and write out those records that match from File1.txt to File3.txt? I don't want to buy an expensive application and I don't want to write a script from scratch.
    Thanks

    Take a look at the diff utility in the Terminal. A google search for it should provide enough info on how to use it. Basic is diff file1 file2
    Or, type "info diff" in the command line.
    Oops. I read too much into your request and got it backwards. Seems grep or awk would work for what you want.
    Message was edited by: Barney-15E

  • Merge text file with condition

    I have two text files (report1.txt and report2.txt) that I want to merge with conditions:
     - Matching rows that have same "ID" and same "TranVal", will keep only one instance
     - Mismatching rows that have same "ID" both rows from 2 file, but column "TranVal" has different value, then the row from report2.txt will replace row in report1.txt
     - Any "ID" that exists in one textfile but not the other one, will be copied to the final merged file
    report1.txt:
    TranDate,ID,TranVal,Comment
    061211,9840,40,done
    061211,9841,30,done
    061211,9842,28,done
    report2.txt:
    TranDate,ID,TranVal,Comment
    061211,9840,40,done
    061211,9841,89,done
    061211,9843,25,done
    Final result should be:
    merge.txt:
    TranDate,ID,TranVal,Comment
    061211,9840,40,done
    061211,9841,89,done
    061211,9842,28,done
    061211,9843,25,done

    Hi,
    I just checked Import-Csv option. I will be able to manage this problem if i can get it in CSV format and work with objects, BUT the problem is in my real file
    the file-format is different which is not comma-separated, instead have "-" as seperator. To simplify the problem i used comma in my question.
    TranDate,ID,TranVal,Comment
    061211-9840-40-done
    Could
    you suggest me if there is any way to convert "-" separators to CSV?

Maybe you are looking for

  • Second hand iMac - Reinstall Lion

    I have a friend who purchased a 2010 iMac that was originally shipped with Snow Leopard but was later upgraded to Lion by the original owner. He would like to wipe this system clean and reinstall Lion, but I believe he will have to download his own c

  • Error "Available quantity in bin is zero" with FM: L_TO_CREATE_MULTIPLE

    Hi, all,    I encounter  one problem wtih BAPI:  L_TO_CREATE_MULTIPLE. I want to transfer 100 batches from P01 storage type to P02 storage type ,  this function module show error "Available quantity in bin is zero".   But the TO is created and this T

  • Premiere Pro Direct Send to SpeedGrade; Error Box Footage Couldn't Be Found

    I recently did a clean install and now when I try to send a clip from Premiere Pro to SpeedGrade the following happens: SpeedGrade Opens As Normal SpeedGrade displays a large red boxIndicates the The Sequence / Video File could not be found The same

  • Uninstall Trial version of Technical Communication Suite 2

    I decided to try out CS2. I decided that I didn't need all the features and that I'd be okay just using the software I already had installed. Long story, short, I ran the uninstaller and it did not uninstall Acroat 9 Pro Extended. Because this is sti

  • Hard drive how do I format.

    How do I format my samsung drive? I want to replace the apple hardrive with a bigger capacity hardrive. When I swapped it and booted from the install disks, it would not boot up because my new hard drive was not formatted, how do I format??? when the