File Formatting


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: File Formatting

  1. #1
    RHuber Guest

    File Formatting


    I'm working on an application to import data from an Excel document (.csv)
    to SQL Server database.

    After doing my homework on working with instances of Excel, I've finally
    realized that I can't make the assumption that Excel will be available on
    the end machine... which brings me back home to a delimited file. My question...

    Is there a way to convert a .csv file to a tab-delimited text file without
    creating an instance of Excel? Of course, I can easily open it as comma
    delimited, but since the some of the data itself contains commas, I need
    to work with something different.

    Any suggestions?


  2. #2
    Robert Gelb Guest

    Re: File Formatting

    You can go 2 ways here.

    Open the file and replace the commas with tabs. Easy enough. Read the
    contents into a string, then do Replace(sContents, ",", " ")

    Or you could open the file in ADO/JET/Text ISAM into a recordset and just
    dump the file to SQL server either using inserts (the slow way) or using my
    really cool BULK INSERT class. You can get it here.

    http://www.vbrad.com/pf.asp?p=Source/src_bcp.htm

    --
    Robert Gelb
    www.vbRad.com
    Source, Tips, Tricks, Components

    "RHuber" <bobhuber@pacbell.net> wrote in message
    news:3acb882b$1@news.devx.com...
    >
    > I'm working on an application to import data from an Excel document (.csv)
    > to SQL Server database.
    >
    > After doing my homework on working with instances of Excel, I've finally
    > realized that I can't make the assumption that Excel will be available on
    > the end machine... which brings me back home to a delimited file. My

    question...
    >
    > Is there a way to convert a .csv file to a tab-delimited text file without
    > creating an instance of Excel? Of course, I can easily open it as comma
    > delimited, but since the some of the data itself contains commas, I need
    > to work with something different.
    >
    > Any suggestions?
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center