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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:34:54+00:00 2026-06-14T23:34:54+00:00

So I am trying to read a csv file that essentially is a list

  • 0

So I am trying to read a csv file that essentially is a list of data separated by words, and I what I have done so far is used ReadAllLines and then from there separated with text.Split(‘,’);
The only problem is I just read about this sort of list/array class method rather than creating an actual array, so I have no clue how to call it, or use it. Here is what I have so far:

using System;
using System.IO;
public class Earthquake
{
    public double Magnitude { get; set; }
    public string Location { get; set; }
    public double Latitude { get; set; }
    public double Longitude { get; set; }
    public double depth { get; set; }
    public string date { get; set; }
    public string EventID { get; set; }
    public string URL { get; set; }
    public Earthquake(double magna, string locate, double lat, double longi, double dept, string dat, string Event, string website)
    {
        Magnitude = magna;
        Location = locate;
        Latitude = lat;
        Longitude= longi;
        depth = dept;
        date = dat;
        EventID = Event;
        URL = website;
    }

}
public class ManageData
{

    public int count;
    public void getData()
{
    string[] text = File.ReadAllLines(@"Earthquakes.csv");
    foreach (string word in text[count].Split(','))
    {
        //here i want to put each data in the Earthquake class
    }

}

}
  • 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-14T23:34:55+00:00Added an answer on June 14, 2026 at 11:34 pm

    You may replace

    foreach (string word in text[count].Split(','))
        {
            //here i want to put each data in the Earthquake class
        }
    

    with following code lines and see if it helps

    foreach (string line in text)
    {
      string[] myColumns = line.Split(',');
    
      EarthQuake eQ = new EarthQuake(myColumns[0],myColumns[1],myColumns[2],myColumns[3],myColumns[4],myColumns[5],myColumns[6],myColumns[7],myColumns[8]);
      //Add eQ into a list you want to save
    
    }
    

    This assumes the columns are in same order. If the order is different than rather than using this constructor, use default constructor and then assign values to the properties of EarthQuake class accordingly.

    Hope that helps.

    • 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 and sort a csv file that has data that
I have a csv file that I am trying to read in R, for
I am trying to read a file using csv.DictReader I have a field that
I'm trying to read a csv file into R that has date values in
So I have this array list that is populated using a csv file. Once
I'm trying to read a csv file that holds several values in every cell
I have created CSVReader and I am trying to read csv file from assets
I have a time series(a csv file) data that looks like below. Each observation
I have a simple .csv file that has that I want to extract data
I have written a generic CSV file reader that I'm trying to use to

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.