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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:34:17+00:00 2026-06-16T07:34:17+00:00

Normally, I do something like IFS=’,’ columns=( $LINE ) where $LINE is a line

  • 0

Normally, I do something like

IFS=','
columns=( $LINE )

where $LINE is a line from a csv file I’m reading.

However, how do I handle a csv file with embedded commas? I have to handle several hundred gigs of file so everything needs to be done quickly, i.e., no multiple readings of a line, definitely no loops (last time I tried that slowed it down several factors).

The general structure of the code is as follows

FILENAME=$1
cat $FILENAME | while read LINE
do
    IFS=","
    columns=( $LINE )
    # affect columns changes here
    newline="${columns[*]}"
    echo "$newline"
done

Preferably, I need something that goes

FILENAME=$1
cat $FILENAME | while read LINE
do
    IFS=","
    # code to tell bash to ignore if IFS is within an open quote
    columns=( $LINE )
    # affect columns changes here
    newline="${columns[*]}"
    echo "$newline"
done

Any tips would be appreciated. Otherwise, I’ll probably switch to using another language to handle this stuff.

  • 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-16T07:34:19+00:00Added an answer on June 16, 2026 at 7:34 am

    Probably embedded commas is just the first obvious problem that you encountered while parsing those CSV files.

    Future problems that might popped are:

    • embedded newline separator characters
    • embedded utf8 chars
    • special treatment for whitespaces, empty fields, spaces around commas, undef values

    I generally tend to follow the philosophy that If there is a (reputable) module that parses some
    format you have to parse, use it instead of making a homebrew

    I don’t think there is such a thing for bash, but there are some for Perl. I’d go for Text::CSV_XS. Being written in C I expect it to be very fast.

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

Sidebar

Related Questions

Normally to use Ruby libraries from command line I can do something like: ruby
I have a SQL*Loader control file that has a line something like this: FIELDS
Normally the code for using the dbContext from Entity Framework looks something like this:
Normally, we get first value that way: $(#color option:first).val() But I need something like
Normally you would use something like attr_accessible :name, :email to allow for mass assignment
Normally when you iterate through a mysql result you do something like this: while
Normally, the UITableView is something like this: [ cell 1 ] [ cell 2
Normally, I can can set the TargetControlID server side using something like this: AutoCompleteExtender
in the webconfig you normally have something like <authentication mode=Forms> <forms loginUrl=Logon.aspx name=.ASPXFORMSAUTH> </forms>
Normally, you'd use something like: glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); glEnable(GL_LINE_SMOOTH); glLineWidth(2.0f); glVertexPointer(2, GL_FLOAT, 0, points);

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.