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

  • SEARCH
  • Home
  • 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 6723639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:35:34+00:00 2026-05-26T09:35:34+00:00

I have a csv with column headings. One column heading is DATE. If I

  • 0

I have a csv with column headings. One column heading is “DATE”. If I want to generate two CSVs split into before DATE and after/including DATE is there a way to do this without procedurally looping? I have noticed most of the list functions are suited for filtering by row.

  • 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-26T09:35:35+00:00Added an answer on May 26, 2026 at 9:35 am

    I’ll assume you already have your data parsed into something like this:

    val myDoc = List(
      List("ID", "NAME", "DATE", "DESC"),
      List("1", "a", "1990", "x"), 
      List("2", "b", "1991", "y")
    )
    

    Now we can use splitAt and unzip to pull the list apart. Note that I’m assuming a lot about the data—in real code we’d want to check that the list is non-empty and that the header actually contains a "DATE" column.

    def split(doc: Seq[Seq[String]]) = {
      val i = doc.head.indexOf("DATE")
      doc.map(_.splitAt(i)).unzip
    }
    

    We can apply it to our test data:

    scala> val (b, a) = split(myDoc)
    b: List[Seq[String]] = List(List(ID, NAME), List(1, a), List(2, b))
    a: List[Seq[String]] = List(List(DATE, DESC), List(1990, x), List(1991, y))
    

    This looks reasonable to me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two CSV files with a common column and I want to Join
I have a 4-column CSV file. I want to sort the lines, such that,
I have a CSV with keywords in one column and the number of impressions
I have a csv file to read, but in one column there are some
I have a large number of csv files that I want to read into
I have a csv file which contains a column named query. One of the
I have a CSV file that has only 1 column, but has close to
I have a CSV file. The first row will always contain column headers. Depending
I have a csv that looks like this: blah,blah, blah, blah ect, ect,column 3
I have CSV data loaded into a multidimensional array. In this way each row

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.