Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Phoenix, Arizona, USA
    Thanked 0 Times in 0 Posts

    Automated conversion of CSV to Tab Delimited

    Now that a project has come to the point of being put into production, one very large stumbling block came up - how to convert a file that is FTP'd from a Unix box to a Win NT box into a Tab delimited file without human intervention. Does someone have a method by which I can do the necessary conversion? The resultant file goes into a VB process what is looking for Tab delimited strings and just converting the commas in the CSV file to tabs will not work (some of the data fields contains <img src=/w3timages/censored.gif alt=censored border=0> commas <img src=/S/bouncenburn.gif border=0 alt=bouncenburn width=31 height=31> ) Using Excel 97 and NT 4 SP6. TIA
    "Somebody left the cork out of my lunch." - W. C. Fields

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Pittsburgh, Pennsylvania, USA
    Thanked 342 Times in 335 Posts

    Re: Automated conversion of CSV to Tab Delimited

    Can't you modify the VB code to use comma delimited?

    Other options:
    I assume that the fields which contain commas are within fields with quotes? Are all the fields delimited by commas and within quotes you could then replace the comma between the quotes with a tab between quotes (that is [","] with a ["<tab>"])

    Otherwise (if some fields have quotes and others don't) you could open the text file in VBA and read it character by character and replace any commas, that are NOT within quoted fields with tabs and leave the others alone: set a "flag" at the first quote and ignore any commas until you hit the end quote to "reset" the flag. You would replace any commas only when the "flag" is reset.


Posting Permissions

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