Copy a text file data specific position

Discussion in 'Requests' started by Amit kumar-MCA, Nov 21, 2018.

    
Tags:
  1. Amit kumar-MCA

    Amit kumar-MCA New Member


    Hello friend ,
    I have a text file that has 30 lines. I want to copy of this file to another file .it is posible text read and write function.

    " But in my scenario i want to copy the the data of line number 20 to 28 not whole file. Is it possible ? " When we can use the file read then it copy whole data . Please suggest .
     


  2. Maulik Patel

    Maulik Patel Active Member


    Hi,

    Kindly follow below steps

    • Understand File Read and Write functions from sample code
    • Create a your own function
    • read file in loop
    • put your condition for line number in loop
    • if your condition is true then write that text in new file
    • break your loop
     


  3. Amit kumar-MCA

    Amit kumar-MCA New Member


    yes , Using $$Loopindex we can find the Correct line and using loop we can call it only required number of time . but in that case it print the file first line value not
     


  4. Maulik Patel

    Maulik Patel Active Member


    You are changing your requirement, earlier you asked for read and write possibilities and now you are talking about printing. Please confirm your requirement first then someone can help you.
    OR
    Might I have not understood your requirement clearly. So please explain in detail.
     


  5. Amit kumar-MCA

    Amit kumar-MCA New Member


    Hi , Actually here some confusion.. I don't change the requirement . I can repeat again .

    Let I have one file "Demo.txt " that contain are -

    Line:1: A
    Line:2:B
    Line:3:C
    Line:4:Output show after this line
    Line:5:E
    Line:6:F
    Line:7:G
    EOF

    Now Required output is - (We Want)
    Line:5:E
    Line:6:F
    Line:7:G

    we can use file and read and write function . we can also find the line number using $$Loopeindex but LoopIndex give the proper outpur but $$FileRead or $$FileReadRaw give the following output - (Came after code execution)
    Line:5:A
    Line:6:B
    Line:7:C

    not the above output.
     


Share This Page