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 8502537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:30:48+00:00 2026-06-11T01:30:48+00:00

I have a CSV file which needs to separate values into separate CSV file.

  • 0

I have a CSV file which needs to separate values into separate CSV file.

It already has an existing code:\

  1. First sub file needs a file that contains value in first and second fields

    egrep "^[^,]+,[^,]+," orig.csv > suba.csv

  2. Second sub contains files containing values in first but empty in the second

    egrep "^[^,]+,," orig.csv > subb.csv

From what I understand the ^[^,]+, means must start with a value but the value must not be a comma then followed by a comma.

We have a new requirement that the fifth column must not be a blank:

Here is what I thought it should be but unfortunately it still receives the value with the fifth column with no value

egrep "^[^,]+,[^,]+,[^,]+,[^,]+,[^,]+" orig.csv > suba_2.csv

Any ideas?

  • 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-06-11T01:30:50+00:00Added an answer on June 11, 2026 at 1:30 am

    Try:

    egrep "^[^,]+,[^,]+,[^,]+,[^,]+,[^, ]+" orig.csv
    

    I am suspecting there is whitespace in your fifth element.

    Your regex worked for me with the following input:

    % cat orig.csv
    1,2,3,4,5,6,7,8,9,10
    1,2,3,4,,6,7,8,9,10
    1,2,3,4,5
    1,2,3,4,
    % egrep "^[^,]+,[^,]+,[^,]+,[^,]+,[^,]+" orig.csv
    1,2,3,4,5,6,7,8,9,10
    1,2,3,4,5
    % 
    

    But not when I put a space at the end of the last line 1,2,3,4, .

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

Sidebar

Related Questions

I have CSV file which has timestamp in the first column as shown below
I need to read a CSV file which has fields that have a comma,
Little Background: I have csv file which has lots of rows and each row
I have a CSV file which has the following format: id,case1,case2,case3 Here is a
I have a Testing project that contains a csv file which a webtest uses
I have a PHP app that creates a CSV file which is forced to
I have a CSV file supplied from a client which has to be parsed
I have a script that generates a csv file using the following code: header('Content-type:
I have a csv file which has two columns, a numeric ID ( IDVAR
I have a MySQL db which needs to be exported to a CSV file.

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.