Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By JosAH

Thread: Text processing-Copying specific lines from multiple text file to one file

  1. #1
    john007 is offline Member
    Join Date
    Jun 2015
    Posts
    6
    Rep Power
    0

    Exclamation Text processing-Copying specific lines from multiple text file to one file

    Need a code which does following:

    1. Creates a MASTER_DATA.txt file.
    2. Copies specific lines(lets say can be a line 5, 7..)data from multiple .txt files placed in a folder to a MASTER_DATA.txt file.

    Thanks in advance
    Regards,
    John

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    29

    Default Re: Text processing-Copying specific lines from multiple text file to one file

    We're not a code factory here but we're willing to help you if you try to do it yourself but you're stuck. Show us what you have attempted yourself.

    kind regards,

    Jos
    john007 likes this.
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    john007 is offline Member
    Join Date
    Jun 2015
    Posts
    6
    Rep Power
    0

    Default Re: Text processing-Copying specific lines from multiple text file to one file

    i have written a .bat file but wanna do the same through java.
    Here is the code.
    I donot know proper syntax in java.

    here is the code


    @echo off
    for %%f in (*.txt) do (
    setlocal enableextensions enabledelayedexpansion
    set revision1=
    for /f "delims=" %%a in (%%~nf.txt) do (
    set line=%%a
    if "x!line:~0,10!"=="xRECORDTYPE" (
    set revision1=!line:~10!
    )
    )
    echo|set /p = !revision1! >> test.txt


    set revision1a=
    for /f "delims=" %%a in (%%~nf.txt) do (
    set line=%%a
    if "x!line:~0,5!"=="xIDENT" (
    set revision1a=!line:~5!
    )
    )
    echo|set /p = !revision1a! >> test.txt

    set revision2=
    for /f "delims= " %%a in (%%~nf.txt) do (
    set line=%%a
    if "x!line:~0,17!"=="xTOTAL_FLIGHT_TIME" (
    set revision2=!line:~17!
    )
    )


    echo|set /p = !revision2! >> test.txt
    set revision3=
    for /f "delims= " %%a in (%%~nf.txt) do (
    set line=%%a
    if "x!line:~0,20!"=="xTOTAL_OPERATION_TIME" (
    set revision3=!line:~20!
    )
    )

    echo|set /p = !revision3! >> test.txt

    set revision4=
    for /f "delims= " %%a in (%%~nf.txt) do (
    set line=%%a
    if "x!line:~0,23!"=="xOTHER[AVG_MONTHLY_USAGE" (
    set revision4=!line:~23!
    )
    )
    echo|set /p = !revision4! >> test.txt
    echo. >> test.txt
    endlocal
    )

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,007
    Rep Power
    34

    Default Re: Text processing-Copying specific lines from multiple text file to one file

    I donot know proper syntax in java.
    You will need to learn java syntax before you will be able to write a java program. One place to start is the tutorial: The Really Big Index
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 1
    Last Post: 07-02-2014, 01:59 PM
  2. Replies: 0
    Last Post: 07-02-2014, 01:23 PM
  3. Replies: 2
    Last Post: 05-03-2013, 03:55 AM
  4. Writing multiple lines to text file at once
    By Plex in forum New To Java
    Replies: 14
    Last Post: 11-08-2010, 10:17 PM
  5. Deleting multiple lines of text from a file
    By barman in forum New To Java
    Replies: 4
    Last Post: 06-29-2010, 10:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •