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. Visual Basic
  4. Text file to CSV file

Text file to CSV file

Scheduled Pinned Locked Moved Visual Basic
questionhelp
6 Posts 4 Posters 1 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.
  • C Offline
    C Offline
    csridevi
    wrote on last edited by
    #1

    How can I read the text file from different position say from position 03(column 1), position 04 to 19 (column2) ..and so on. till the length of record.Then how can I get the values and write the values in csv format?.Please Help out. C.Sridevi

    P 1 Reply Last reply
    0
    • C csridevi

      How can I read the text file from different position say from position 03(column 1), position 04 to 19 (column2) ..and so on. till the length of record.Then how can I get the values and write the values in csv format?.Please Help out. C.Sridevi

      P Offline
      P Offline
      pmarfleet
      wrote on last edited by
      #2

      Have you looked at the classes in the System.IO namespace? The File class has static methods for reading and writing text data to files. I suggest you read the documentation and attempt to write some code based on the examples in MSDN. If you have any specific problems after doing this, come back and ask again. Paul

      C 1 Reply Last reply
      0
      • P pmarfleet

        Have you looked at the classes in the System.IO namespace? The File class has static methods for reading and writing text data to files. I suggest you read the documentation and attempt to write some code based on the examples in MSDN. If you have any specific problems after doing this, come back and ask again. Paul

        C Offline
        C Offline
        csridevi
        wrote on last edited by
        #3

        I could read and write the line using stream reader and stream writer.But I need to get the values from a column in a text file.After getting those column values,i need to write it in csv format..how i do this? C.Sridevi

        G 1 Reply Last reply
        0
        • C csridevi

          I could read and write the line using stream reader and stream writer.But I need to get the values from a column in a text file.After getting those column values,i need to write it in csv format..how i do this? C.Sridevi

          G Offline
          G Offline
          GuyThiebaut
          wrote on last edited by
          #4

          Hi, Here is how to read the file in one chunk (very fast): Dim inString As String Dim stringArray() As String fileReader = New System.IO.StreamReader(FileName) inString = fileReader.ReadToEnd() fileReader.Close() stringArray = inString.Split(vbLf) You will then have to parse each line, in stringArray, separating fields at the relevant points. That is where you will have to do the work. What you have asked for does not have a quick and easy answer. Read up on CSV file formats via google then apply your VB .Net knowledge to parsing each line. Hope this helps

          You always pass failure on the way to success.

          T 1 Reply Last reply
          0
          • G GuyThiebaut

            Hi, Here is how to read the file in one chunk (very fast): Dim inString As String Dim stringArray() As String fileReader = New System.IO.StreamReader(FileName) inString = fileReader.ReadToEnd() fileReader.Close() stringArray = inString.Split(vbLf) You will then have to parse each line, in stringArray, separating fields at the relevant points. That is where you will have to do the work. What you have asked for does not have a quick and easy answer. Read up on CSV file formats via google then apply your VB .Net knowledge to parsing each line. Hope this helps

            You always pass failure on the way to success.

            T Offline
            T Offline
            txmrm
            wrote on last edited by
            #5

            There is no need to write a parser to split the lines into a string array. Look at the Microsoft.VisualBasic.FileIO.TextFieldParser class. It will parse fixed width or CSV text files a line at a time.

            G 1 Reply Last reply
            0
            • T txmrm

              There is no need to write a parser to split the lines into a string array. Look at the Microsoft.VisualBasic.FileIO.TextFieldParser class. It will parse fixed width or CSV text files a line at a time.

              G Offline
              G Offline
              GuyThiebaut
              wrote on last edited by
              #6

              Thanks for that. Oh man - I wrote a csv classs to read and write csv files:wtf: I guess I learnt about csv files in the process though:sigh:

              You always pass failure on the way to success.

              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