locked
How can I start reading and writing data from certain line until end of the file in console app? RRS feed

  • Question

  • Parent directory: ftp://cddis.gsfc.nasa.gov/gnss/products/ionex/2017/

    All files begin with codg and I get 365 file in this directory.

    I want to read data that begins with this line as follow until end of file, then to write data to text file for all files respectively.

         1                                                      START OF RMS MAP

    Monday, August 13, 2018 12:07 AM

Answers

  • Check this:

    var lines = File.ReadLines( filename ).SkipWhile( s => !Regex.IsMatch( s, @"^\s*1\s+START OF RMS MAP\s*$" ) );
    
    foreach( string line in lines )
    {
       Console.WriteLine( line );
       // . . .
    }
    
    

    Sunday, August 12, 2018 12:33 PM

All replies

  • Hello

    I am beginner. I'd like to start reading this line as follow:

         1                                                      START OF RMS MAP

    My file is: ftp://cddis.gsfc.nasa.gov/gnss/products/ionex/2017/001/codg0010.17i.Z

    • Merged by KareninstructorMVP Monday, August 13, 2018 12:45 AM Original poster can't access their account
    Sunday, August 12, 2018 12:04 PM
  • Check this:

    var lines = File.ReadLines( filename ).SkipWhile( s => !Regex.IsMatch( s, @"^\s*1\s+START OF RMS MAP\s*$" ) );
    
    foreach( string line in lines )
    {
       Console.WriteLine( line );
       // . . .
    }
    
    

    Sunday, August 12, 2018 12:33 PM
  • Check this:

    var lines = File.ReadLines( filename ).SkipWhile( s => !Regex.IsMatch( s, @"^\s*1\s+START OF RMS MAP\s*$" ) );
    
    foreach( string line in lines )
    {
       Console.WriteLine( line );
       // . . .
    }

    How can I integrate this into directory containing many files? Because I would like to write specific data among 'START OF RMS MAP' and 'END OF RMS MAP' to text file.

    I have 365 files that begins with codg in this directory as follow...

    Directory: ftp://cddis.gsfc.nasa.gov/gnss/products/ionex/2017/






    • Edited by SuatYAZICI Sunday, August 12, 2018 6:57 PM
    Sunday, August 12, 2018 4:48 PM
  • Hello,

    If you are the person who posted here (as I doubt two people in one day submit so similar a question) please do not do this by posting as a different user.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Monday, August 13, 2018 12:24 AM
  • Hello. It was me but I can't access other account. That's why I made topic again by singing up again.

    Sorry about that.

    Monday, August 13, 2018 12:39 AM
  • Hi YStuat,

    >>How can I integrate this into directory containing many files? 

    Do you have any marks in the file name of these 365 files? If yes, you could search file names first. If no, the only thing we could do is to foreach all the files and then read text from each file to match.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, August 14, 2018 8:25 AM
  • If I don't misunderstand "do you have any marks in the file name of these 365 files?"

    text file format is codgddd0.17i

    ddd: day of the year

    All files begin with codg and ddd increases arithmetically beginning with 001 until 365 and also end with ".17i".

    Tuesday, August 14, 2018 7:27 PM