SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need To Convert TXt To CSV

    Hi,

    I need to convert a text file into a csv format any
    simple way to do it.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    how do you know where the commas are supposed to go?

    and where are you going to use this csv file? i bet you could probably just use the txt file
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,788
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    If the file already contains comma separators between the fields then it already is a CSV irrespective of what file extension it uses. If it doesn't already contain the commas then it presumably contains some other character as a field separator and it will just be a simple matter of using a Regular Expression in the language of your choice to convert that separator into commas.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It containe commas so i'll try changing the extension to .csv I also
    have CSVed

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    if it contains commas, then it already is a "comma-separated values" file

    most places where you can use a csv file don't actually require that you change the extension to .csv

    so perhaps you don't need to do anything at all

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I fixed it thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •