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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Comma Delimted Windows Application

Comma Delimted Windows Application

Scheduled Pinned Locked Moved C#
questionhelp
6 Posts 5 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.
  • N Offline
    N Offline
    ndeza
    wrote on last edited by
    #1

    Hi All, I have an application that reads .csv data. My problem is that the is a value that is not read, it will read the number before the comma, but this is one number. How do i make the app read the full number, e.g.: 1,093? if (_lineItem == 12) { // the rows that will be added into the // specified columns dt.Rows.Add(new object[] { _dateParse, _casinoname, _line[3].Replace("\"", "").Replace("," , "")}); } _lineItem++; Thank you,

    D A 2 Replies Last reply
    0
    • N ndeza

      Hi All, I have an application that reads .csv data. My problem is that the is a value that is not read, it will read the number before the comma, but this is one number. How do i make the app read the full number, e.g.: 1,093? if (_lineItem == 12) { // the rows that will be added into the // specified columns dt.Rows.Add(new object[] { _dateParse, _casinoname, _line[3].Replace("\"", "").Replace("," , "")}); } _lineItem++; Thank you,

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      Can you post sample data from your csv file? And do you have any idea how large the number would be ie minimum or maximum value?

      जय हिंद

      N 1 Reply Last reply
      0
      • N ndeza

        Hi All, I have an application that reads .csv data. My problem is that the is a value that is not read, it will read the number before the comma, but this is one number. How do i make the app read the full number, e.g.: 1,093? if (_lineItem == 12) { // the rows that will be added into the // specified columns dt.Rows.Add(new object[] { _dateParse, _casinoname, _line[3].Replace("\"", "").Replace("," , "")}); } _lineItem++; Thank you,

        A Offline
        A Offline
        AhsanS
        wrote on last edited by
        #3

        Use Excel object in c# to read data from csv files. If there are fields that have comma in them, then they must be in double quotes.

        Ahsan Ullah Senior Software Engineer MCTS 2.0

        1 Reply Last reply
        0
        • D dan sh

          Can you post sample data from your csv file? And do you have any idea how large the number would be ie minimum or maximum value?

          जय हिंद

          N Offline
          N Offline
          ndeza
          wrote on last edited by
          #4

          By sample you mean the fileds that is going to the app? If so here is the data. Day Visitors Sunday, May 3, 2009 1,245 The app reads the Visitors Colomn.

          M D 2 Replies Last reply
          0
          • N ndeza

            By sample you mean the fileds that is going to the app? If so here is the data. Day Visitors Sunday, May 3, 2009 1,245 The app reads the Visitors Colomn.

            M Offline
            M Offline
            musefan
            wrote on last edited by
            #5

            ok that does not look like a CSV to me. Are you sure it's not tab delimited? If you want to parse that data i would suggest you split it using the index of the forth space value, which if that is all the data you have per line you can use LastIndexOf...

            string visitors = line.Substring(line.LastIndexOf(' '));

            ...something like that anyway

            Life goes very fast. Tomorrow, today is already yesterday.

            1 Reply Last reply
            0
            • N ndeza

              By sample you mean the fileds that is going to the app? If so here is the data. Day Visitors Sunday, May 3, 2009 1,245 The app reads the Visitors Colomn.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              Do you know what CSV stands for?? Comma Seperated Values. So, if you put numbers formatted with commas in them into the CSV file, the reader will interpret it as two seperate values. You will have to jump through some custom written parsing logic that you have to write to detect this situation and reparse the line correctly. Or, go back to the export application as have it use a different delimiter, such as a Tab character, or not to format the numbers with commas.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007, 2008

              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