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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:46:45+00:00 2026-06-10T08:46:45+00:00

I am trying to read a CSV file and have it display the contents

  • 0

I am trying to read a CSV file and have it display the contents as a basic list for an Android app. I am using the method given by Kopfgeldjaeger in this thread.

I have added a couple of ‘toasts’ which either display ‘success’ or ‘fail’ at the bottom of the Android screen if the code managed (or didn’t manage) to load the CSV file properly. See below:

  try {
      CSVReader reader = new CSVReader(new InputStreamReader(getAssets().open("file.csv")));
      for(;;) {
          next = reader.readNext();
          if(next != null) {
              list.add(next);
          } else {
              break;
          }
      }
      Toast.makeText(getApplicationContext(), "SUCCESS",
              Toast.LENGTH_SHORT).show();
  } catch (IOException e) {
      e.printStackTrace();
      Toast.makeText(getApplicationContext(), "FAIL",
              Toast.LENGTH_SHORT).show();
  }

When I load the app, I get the ‘SUCCESS’ message, so all is well so far. Now, I’d like to see if I can load any of the data. In Kopfgeldjaeger’s answer, it is suggested that I could access a string using the following code:

list.get(1)[1]

So, in order to check that it’s worked, I try to generate another toast, as follows:

      Toast.makeText(getApplicationContext(), list.get(1)[1],
              Toast.LENGTH_SHORT).show();

This added toast causes the program to fail to load properly. The question is, have I gotten the toast syntax wrong, or is my CSV file not loading properly?

  • 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-10T08:46:47+00:00Added an answer on June 10, 2026 at 8:46 am

    There are a couple of things to check:

    1. Make sure your csv file has a size of at least 2 x 2 entries, otherwise retrieving the data from line index 1 and column index 1 won’t work. For example, print or debug list.size() and list.get(0).length to see if they’re both at least 2.
    2. Confirm that your csv file is actually comma separated, and not e.g. semicolon separated. I have seen occassions where certain software seems to choose its own delimiter.

    As a recommendation: the referenced csv reader is part of ByteCode’s OpenCSV. You may want to include the latest source code or jar from that project. It supports custom delimiter characters and also provides a shorthand for parsing all the csv data into a list of string arrays:

    CSVReader reader = new CSVReader(new FileReader("yourfile.csv"));
    List myEntries = reader.readAll();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read a file using csv.DictReader I have a field that
Using Android (Eclipse) I am trying to read a .csv file and dynamically populate
I have a csv file that I am trying to read in R, for
I am trying to read a very simple but somehow large(800Mb) csv file using
So I have this array list that is populated using a csv file. Once
I have created CSVReader and I am trying to read csv file from assets
I am just trying to read .csv file first time.I have gone through the
I am trying to read this .csv file and here is an example of
I am trying to read a CSV file with accented characters with Python (only
I'm trying to read a csv file into R that has date values in

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.