Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 946233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:52:56+00:00 2026-05-15T22:52:56+00:00

I have a file that has > 10 rows. I want to create 9

  • 0

I have a file that has > 10 rows. I want to create 9 files that each contains equal number or rows, with the 10th file containing that equal number plus any left over.

I currently get the data from the main file by the following:

Dim sData As String

Using sr As New StreamReader(vsFilePath)
    sData = sr.ReadToEnd
End Using

Dim oDataList As New List(Of String)
oDataList.AddRange(sData.Split(Convert.ToChar(ControlChars.Lf)))

How can I take oDataList and parse it into 10 files without having to loop through each file and oDataList to write line by line?

Is there a better way them what I am currently doing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:52:57+00:00Added an answer on May 15, 2026 at 10:52 pm

    If the order of the lines is not important, you can do the following to separate the content in 10 equal portions, otherwise, a double loop through the data (one for counting and storing the lines, the other for writing them) is probably necessary.

    Dim sData As String
    Dim counter As Integer
    Dim sw(10) As StreamWriter
    For i As Integer = 0 To 9 Step 1
        sw(i) = New StreamWriter("path" + something)
    Next
    
    Using sr As New StreamReader("path")
        sData = sr.ReadLine()
        While sData IsNot Nothing
            sw(1 Mod counter).WriteLine(sData)
            counter += 1
            sData = sr.ReadLine
        End While
    End Using
    
    'add a finally block for closing the 10 streams
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a XML file that has the following data, <extcode Type=abc Code=12345 />
I have a .dat file that is essentially ; delimited file and I'm trying
Suppose that I have a huge SQLite file (say, 500[MB]) stored in Amazon S3
Suppose that I have a huge SQLite file (say, 500[MB]). Can 10 different python
I'm using PyTables 2.2.1 w/ Python 2.6, and I would like to create a
My story: I want to make a thing which is as simple as a
I have a Web application (Help Desk Ticket System) with an inbox to monitor
I'm stumped by a seemingly simple problem. In my ASP.NET page, I have a
Im making a (small) site in php & mysql. The mysql database consists of
I'm interested in zipping the text output from a JSON object on a server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.