Visual Basic Read Text File Comma Delimited

  1. #1

    ngreenwood6 is offline

    Thread Starter

    Hyperactive Member


    read comma delimited text file

    Can anyone requite me a basic instance of how to read a comma delimited text file? I desire to have a new line for each row. For case it would be (writer,book,location).

    john,c#,new york
    tim,visual basic, california

    If I helped you please rate me.


  2. #2

    Re: read comma delimited text file

    That is the very essence of human beings and our very unique capability to perform circuitous reasoning and actually utilise our perception to further our understanding of things. We like to solve problems. -Kleinma

    Does your code in mail #46 look like my lawmaking in #45? No, it doesn't. Therefore, wrong is how it looks. - jmcilhinney


  3. #3

    ngreenwood6 is offline

    Thread Starter

    Hyperactive Member


    Re: read comma delimited text file

    That is a horrible case simply so you lot know and I never understand why people respond to a question if they arent going to answer. I could have posted some links too if you desire to come across some.

    If I helped yous please rate me.


  4. #4

    Re: read comma delimited text file

    What do yous mean "read a comma delimeted textfile"? Just use System.IO.StreamReader to read the file. Beyond that we need a meliorate description.

    Also, a row is only a row because it's on its own line, in which case why would you add together another line to it, its already separated by a line if its a row.


  5. #5

    Re: read comma delimited text file

    "That is a horrible example but and then yous know and I never empathise why people respond to a question if they arent going to respond."
    one) What makes it a horrible instance? It's code that reads in a CSV file.... what more do you want?
    2) Sometimes that is the answer... if we had to go effectually typing out real answers that have been answered a dozen times before, all with decent, working lawmaking... I doubt we'd have time for much else. Sometimes a link (or two or three) in the correct direction is what'southward needed. What would you take wild_bill say? Regurgitate the commodity? pffft!

    -tg


  6. #6

    ngreenwood6 is offline

    Thread Starter

    Hyperactive Fellow member


    Re: read comma delimited text file

    @techgnome

    reply 1 = i asked for a SIMPLE example that is far across uncomplicated. A uncomplicated example would be this which I came up with on my ain past the way:

    Code:

    StreamReader sr = File.OpenText(@"c:\test.txt"); string due south = sr.ReadLine() while(s != null) { string[] t = s.Split up(','); Panel.WriteLine(t[0]); Console.WriteLine(t[one]); sr.ReadLine(); }
    reply two = if information technology has been answered here before and so why not link to where it was answered here

    If I helped you please rate me.


  7. #7

    Re: read comma delimited text file

    You could too apply the textfieldparser object.

    Grade: http://msdn.microsoft.com/en-us/libr...eldparser.aspx
    Example: http://msdn.microsoft.com/en-us/library/cakac7e6.aspx

    It has a belongings HasFieldsEnclosedInQuotes, which will help you handle commas enclosed within quotes, which would pause your electric current implementation with the split function.


  8. #8

    Re: read comma delimited text file

    uncomplicated is as simple does... until shrimp gumbo shows upwardly and you endeavor to read in a value that has a comma in the middle mucking it all up. Merely because information technology's more complicated than you can deal (I'll acknowledge information technology was more than I could follow besides) doesn't brand it a horrible example. A simple "Thank you for that, simply it's a bit more complicated than I needed, practise you take something simpler?" probably would accept gone over better - like I'yard one to talk, right? *slaps cocky*

    And I never said it had been answered Here earlier... merely that it is something that had been answered in one form or another before.

    it's the end of the day, getting on the stop of the week and I'm feeling a bit punchy it seems, and there'south C# code in the VB.NET forums. bleh.

    -tg


  9. #9

    ngreenwood6 is offline

    Thread Starter

    Hyperactive Member


    Re: read comma delimited text file

    @negative0 thanks for that. I volition more than likely use that course to read the text file. I was thinking of going with an xml file so that I could do it by titles like (<author><book>, etc) just it looked to complicated.

    @techgnome yes its been a long week and i myself was getting a piffling picky. I appreciate the response just sometimes go tired of asking for something basic that I can build off of and instead getting something and so complex that microsoft couldnt figure it out lol. yep i code in c# merely the responses through the c# forums are alot slower and i can usually catechumen the lawmaking from vb into c#

    If I helped you please charge per unit me.


  10. #10

    Re: read comma delimited text file

    as a side note - did you know that you tin can use ADO to read CSV files? I just remembered that, and it isn't too difficult either, AND it has the added bonus of being able to handle quoted text also.

    -tg


  11. #11

    Re: read comma delimited text file

    Quote Originally Posted by techgnome View Post

    equally a side note - did you lot know that you can use ADO to read CSV files? I just remembered that, and information technology isn't too difficult either, AND information technology has the added bonus of beingness able to handle quoted text besides.

    -tg

    I was hoping he would get that from the article. Granted in that location was more data than needed, they had a very good chunk of code for using ado.net to read csv.

    That is the very essence of human beings and our very unique capability to perform complex reasoning and actually use our perception to further our understanding of things. We similar to solve problems. -Kleinma

    Does your lawmaking in post #46 look like my code in #45? No, it doesn't. Therefore, wrong is how information technology looks. - jmcilhinney


  12. #12

    Re: read comma delimited text file

    You tin can employ ADO, but then you can also only practise this:

    Code:

    Cord values() = IO.File.ReadAllText("MyCSV.csv").Dissever(","c, StringSplitOptions.RemoveEmptyEntries)

Posting Permissions

  • You lot may not mail new threads
  • You may not post replies
  • Yous may not post attachments
  • You may not edit your posts
  • BB code is On
  • Smilies are On
  • [IMG] code is On
  • [VIDEO] code is On
  • HTML lawmaking is Off

Click Here to Expand Forum to Full Width

Visual Basic Read Text File Comma Delimited

Source: https://www.vbforums.com/showthread.php?574198-read-comma-delimited-text-file

0 Response to "Visual Basic Read Text File Comma Delimited"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel