locked
VBA to read a text file, find a word, and starting from that word to end of file - write in other file RRS feed

  • Question

  • I have a text file with 10000 lines.

    i want a code to search for a word and then write the remaining data to another text file.

    Example - 

    2016-07-23 09:14:40,221 INFO  - HostName   : ROWS0010
    2016-07-23 09:14:40,221 INFO  - HostAddress: 10.10.69.44
    2016-07-23 09:14:40,222 INFO  - ModuleName : Module_f98614df_4d690f3b_SEWS0127
    2016-07-23 09:14:40,222 INFO  - ModuleURL  : rmi://10.10.69.44:4029
    2016-07-23 09:14:40,222 INFO  - 
    2016-09-24 09:07:21,434 INFO  - Scheduler Shut down!!!
    2016-09-24 09:09:04,222 INFO  - Release Version     : V10000.1.0.30_20141202.00
    2016-09-24 09:09:04,222 INFO  - Home Directory      : E:\Siemens\DISPAT~1\SCHEDU~1\bin\\..
    2016-09-24 09:09:04,238 INFO  - Log files Directory : E:\Siemens\Dispatcher10\Logs\Dispatcher
    2016-09-24 09:09:04,238 INFO  - Java Version        : 1.7.0_45
    2016-09-24 09:09:04,300 INFO  - Start Time          : Sep 24, 2016 09:09:04
    2016-09-24 09:09:04,331 INFO  - Scheduler URL rmi://localhost:4028
    2016-09-24 09:09:13,278 INFO  - 
    2016-09-24 09:09:13,278 INFO  - Scheduler is ready to accept tasks.
    2016-09-24 09:09:50,030 INFO  - 
    2016-09-24 09:09:50,031 INFO  - Following module connected to the scheduler:
    2016-09-24 09:09:50,031 INFO  - --------------------------------------------
    2016-09-24 09:09:50,031 INFO  - HostName   : ROWS0010

    To find - 2016-09-24

    New Text -

    2016-09-24 09:07:21,434 INFO  - Scheduler Shut down!!!
    2016-09-24 09:09:04,222 INFO  - Release Version     : V10000.1.0.30_20141202.00
    2016-09-24 09:09:04,222 INFO  - Home Directory      : E:\Siemens\DISPAT~1\SCHEDU~1\bin\\..
    2016-09-24 09:09:04,238 INFO  - Log files Directory : E:\Siemens\Dispatcher10\Logs\Dispatcher
    2016-09-24 09:09:04,238 INFO  - Java Version        : 1.7.0_45
    2016-09-24 09:09:04,300 INFO  - Start Time          : Sep 24, 2016 09:09:04
    2016-09-24 09:09:04,331 INFO  - Scheduler URL rmi://localhost:4028
    2016-09-24 09:09:13,278 INFO  - 
    2016-09-24 09:09:13,278 INFO  - Scheduler is ready to accept tasks.
    2016-09-24 09:09:50,030 INFO  - 
    2016-09-24 09:09:50,031 INFO  - Following module connected to the scheduler:
    2016-09-24 09:09:50,031 INFO  - --------------------------------------------
    2016-09-24 09:09:50,031 INFO  - HostName   : ROWS0010

    Thursday, October 20, 2016 8:16 AM

All replies

  • Hi Vedaanth,

    Please use "IndexOf("2016-09-24")" in the loop of reading each line.

    I suppose you've learned how to read lines.

    Regards,

    Asnidacchi


    • Edited by Ashidacchi Thursday, October 20, 2016 1:56 PM
    Thursday, October 20, 2016 1:53 PM