DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • How to Convert Excel and CSV Documents to HTML in Java
  • Datafaker 2.0
  • How to Convert CSV to XML in Java
  • Alternative Structured Concurrency

Trending

  • A Deep Dive into Tracing Agentic Workflows (Part 1)
  • Edge Computing in Utility IoT: Two Architecture Patterns That Actually Work
  • How to Format Articles for DZone
  • Master-Class: Understanding Database Replication (Single, Multi, and Leaderless)
  1. DZone
  2. Coding
  3. Java
  4. Parsing a Tab Delimited File Using OpenCSV

Parsing a Tab Delimited File Using OpenCSV

By 
Brian O' Neill user avatar
Brian O' Neill
·
Oct. 24, 14 · Interview
Likes (0)
Comment
Save
Tweet
Share
24.2K Views

Join the DZone community and get the full member experience.

Join For Free

I prefer OpenCSV for CSV parsing in Java.  That library also supports parsing of tab delimited files, here's how:

Just a quick gist:

import au.com.bytecode.opencsv.CSVReader;

public class LoadTest {

    @Test
    public void testLoad(String row) throws IOException, JobNotFoundException, InterruptedException {
        CSVReader reader = new CSVReader(new FileReader("/Users/bone/Desktop/foo_data.tab"), '\t');
        String[] record;
        while ((record = reader.readNext()) != null) {
            for (String value : record) {
                System.out.println(value); // Debug only
            }
        }
    }
}
Gist (computing) Java (programming language) CSV

Published at DZone with permission of Brian O' Neill. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How to Convert Excel and CSV Documents to HTML in Java
  • Datafaker 2.0
  • How to Convert CSV to XML in Java
  • Alternative Structured Concurrency

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook