Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Reading the contents of a txt/CSV file into an array

Reading the contents of a txt/CSV file into an array

Scheduled Pinned Locked Moved C#
csharpdata-structureshelptutorialquestion
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TheBlindWatchmaker
    wrote on last edited by
    #1

    Hello list, I've found myself in a bit of a pickle in trying to do something that is intuitively simple. I'm relatively new to coding, esp. in C#, so I hope you don't mind a novice-level question. Here's what I need to do: 1. I have a text file with some data, and each line in the text file is a number of type "double". 2. I would like the user to be able to click a button on the application's form, navigate to this text file and be able to read ALL available lines (numbers) into an array of doubles. I've figured out how to put the button on the form and the use of the OpenFileDialog. I just don't seem to be doing the reading of data into the array correctly. Your help would be greatly appreciated! Thank you.

    W 1 Reply Last reply
    0
    • T TheBlindWatchmaker

      Hello list, I've found myself in a bit of a pickle in trying to do something that is intuitively simple. I'm relatively new to coding, esp. in C#, so I hope you don't mind a novice-level question. Here's what I need to do: 1. I have a text file with some data, and each line in the text file is a number of type "double". 2. I would like the user to be able to click a button on the application's form, navigate to this text file and be able to read ALL available lines (numbers) into an array of doubles. I've figured out how to put the button on the form and the use of the OpenFileDialog. I just don't seem to be doing the reading of data into the array correctly. Your help would be greatly appreciated! Thank you.

      W Offline
      W Offline
      Weiye Chen
      wrote on last edited by
      #2

      You might want to check out the StreamReader class. It has a ReadLine method which should be able to help you. The Convert class would be able to help you do the conversion from string to double. Weiye Chen Life is hard, yet we are made of flesh...

      A 1 Reply Last reply
      0
      • W Weiye Chen

        You might want to check out the StreamReader class. It has a ReadLine method which should be able to help you. The Convert class would be able to help you do the conversion from string to double. Weiye Chen Life is hard, yet we are made of flesh...

        A Offline
        A Offline
        Alomgir Miah
        wrote on last edited by
        #3

        Check out http://www.codeproject.com/cs/database/CsvReader.asp

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups