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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:33:22+00:00 2026-05-26T16:33:22+00:00

How can I read any type of file from a location and access only

  • 0

How can I read any type of file from a location and access only a particular column to perform some operations on it. Some rows in my column may contain null values too.
Here’s an example:

name | age | sex
xyz  | 22  | F
yyy  | 25  | M
zzz  |     | F
aaa  | 22  | M

I want to access the column age so that I can perform some operations on it, like calculate age group, or performing some other task(s). I have written the code for this function but I still need to access the column to perform this.
I’m pretty new at file reading, hence I need help. I need to do this in java.

I have tried the following:

while (s.hasNextLine()) {
    String line = s.nextLine();
    System.out.println(line+"line ?????");
    String[] cols = line.split("|");
    System.out.println("lets see column only=="+cols[2]);
}

Yet my output is only the 2nd character of the 1st column.

  • 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-26T16:33:23+00:00Added an answer on May 26, 2026 at 4:33 pm

    I have tried

    ...
        String[] cols = line.split("|"); 
    ...
    

    This doesn’t work since split takes a regular expression, and | is a special character when interpreted as a regular expression.

    Instead, try

    String[] cols = line.split("\\|");
                                ^^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any tool that can read a WSDL file and based on the
Is there any book or links that I can read some tutorial about the
Can I read an excel file without using any module? I tried like just
How can I read excel data (office 2007 xlsx) in PHP? Is there any
Can anybody give any working example of how to read/write Unicode text files using
Can someone please explain how Read/Show works.. I cannot find any tutorials on it.
I can't find any mention of the limitations on CoreBluetooth framework's read/write. Does anyone
I am trying to read multiple files (can be of any format i.e. pdf,
I have been able to write a program that can read any text files...
I need to read a large (2000x2000) matrix of binary data from a 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.