+ Reply to Thread
Results 1 to 6 of 6

Import comma separated flat file

  1. #1
    Registered User
    Join Date
    08-02-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Import comma separated flat file

    I have a comma separated data file that I'd like to import into Excel. Unfortunately the fourth column in my text file also contains commas so it creates incorrect columns when I imprt it into Excel. Is there a way to prevent that from happening?

    text file looks like this:
    A00060,DD CDLE,20091124,1230277,FOOTWEAR,DRIFT,17.60,1,17.600

    FOOTWEAR,DRIFT is one column but has comma in the value...

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: import comma separated flat file

    Hi,

    Presumably that was a typo and you meant the fifth column.

    If so is there always and without exception one comma separating words like FootWear and Drift? If so just open the file parsing it in the usual way with commas and then use a helper column to concatenate the 5th and 6th columns before copying the helper column and and pasting it as values in column 5, the finally delete column 6.

    Regards
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    08-02-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: import comma separated flat file

    correct - it's the fifth column. It doesn't contain comms in every row, only some so I can't split and concatenate. Are there any other options?

  4. #4
    Registered User
    Join Date
    12-09-2011
    Location
    Michigan
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: import comma separated flat file

    If you put double quotes around the fields containing commas, and use the Text Import Wizard with delimited by commas, then the field imports as you would like it to.

    Example:
    A00060,DD CDLE,20091124,1230277,"FOOTWEAR,DRIFT",17.60,1,17.600 inputs as eight fields, not nine as you are experiencing

    You may be able to insert the double quotes by putting one after the fourth comma and one before the next comma which has a number after it.
    Alternatively, if your .csv-creating application can put double quotes around all fields, then this will work exactly as above.

    Example:
    "A00060","DD CDLE","20091124","1230277","FOOTWEAR,DRIFT","17.60","1","17.600" also inputs as eight fields, and correctly determines text vs numeric fields

  5. #5
    Registered User
    Join Date
    08-02-2009
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Import comma separated flat file

    Unfortunately all I have is the text file and it has 40000 rows. Going through it one by one to insert quotes will take forever and there is no application to recreate that file. Are there any other options?

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Import comma separated flat file

    assuming only 1 extra coma then import into a single column say col a of excel
    then in col b put
    =IF(LEN(A1)-LEN(SUBSTITUTE(A1,",",""))=8,SUBSTITUTE(A1,",","-",5),A1)
    drag down once done copy col b paste back over itself as special values to remove formulas then split with text to columns
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1