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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:28:17+00:00 2026-05-28T00:28:17+00:00

Is there any Java open source library that supports multi-character (i.e., String with length

  • 0

Is there any Java open source library that supports multi-character (i.e., String with length > 1) separators (delimiters) for CSV?

By definition, CSV = Comma-Separated Values data with a single character (‘,’) as the delimiter. However, many other single-character alternatives exist (e.g., tab), making CSV to stand for “Character-Separated Values” data (essentially, DSV: Delimiter-Separated Values data).

Main Java open source libraries for CSV (e.g., OpenCSV) support virtually any character as the delimiter, but not string (multi-character) delimiters. So, for data separated with strings like “|||” there is no other option than preprocessing the input in order to transform the string to a single-character delimiter. From then on, the data can be parsed as single-character separated values.

It would therefore be nice if there was a library that supported string separators natively, so that no preprocessing was necessary. This would mean that CSV now standed for “CharSequence-Separated Values” data. 🙂

  • 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-28T00:28:18+00:00Added an answer on May 28, 2026 at 12:28 am

    This is a good question. The problem was not obvious to me until I looked at the javadocs and realised that opencsv only supports a character as a separator, not a string….

    Here’s a couple of suggested work-arounds (Examples in Groovy can be converted to java).

    Ignore implicit intermediary fields

    Continue to Use OpenCSV, but ignore the empty fields. Obviously this is a cheat, but it will work fine for parsing well-behaved data.

        CSVParser csv = new CSVParser((char)'|')
    
        String[] result = csv.parseLine('J||Project report||"F, G, I"||1')
    
        assert result[0] == "J"
        assert result[2] == "Project report"
        assert result[4] == "F, G, I"
        assert result[6] == "1"
    

    or

        CSVParser csv = new CSVParser((char)'|')
    
        String[] result = csv.parseLine('J|||Project report|||"F, G, I"|||1')
    
        assert result[0] == "J"
        assert result[3] == "Project report"
        assert result[6] == "F, G, I"
        assert result[9] == "1"
    

    Roll your own

    Use the Java String tokenizer method.

        def result = 'J|||Project report|||"F, G, I"|||1'.tokenize('|||')
    
        assert result[0] == "J"
        assert result[1] == "Project report"
        assert result[2] == "\"F, G, I\""
        assert result[3] == "1"
    

    Disadvantage of this approach is that you lose the ability to ignore quote characters or escape separators..

    Update

    Instead of pre-processing the data, altering it’s content, why not combine both of the above approaches in a two step process:

    1. Use the “roll your own” to first validate the data. Split each line and prove that it contains the requiste number of fields.
    2. Use the “field ignoring” approach to parse the validated data, secure in the knowledge that the correct number of fields have been specified.

    Not very efficient, but possibly easier that writing your own CSV parser 🙂

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

Sidebar

Related Questions

Is there any open source Object to XML serializer in Java that uses writeObject
Is there any Java library that supports hierarchical column? For example (the first three
Is there any Open Source Voice Recognization Library in Java?
Is there any library or open source function that approximate the area under a
Is there any free java library which I can use to convert string in
Is there any open source implementation of LSI in Java? I want to use
I found this open-source library that I want to use in my Java application.
Beside's Ivy's built-in makepom task, I can't find any (Java-centric) open source projects that
Is there any open source screen sharing (or desktop sharing) software that I can
Are there any open source tools that automate the functionality of finding the number

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.