Results 1 to 7 of 7

Thread: BCP CSV files

  1. #1
    Join Date
    Feb 2003
    Location
    Netherlands
    Posts
    63

    Unanswered: BCP CSV files

    Hey guys,

    Sorry if this is a double post, tried to search but couldn't find the answer.

    Does anybody know if there is a bcp version that handles csv files correctly? With that I mean that within the comma delimited file columns that contain a comma that is not a delimeter are enclosed in quotes

    So:
    field1,field2,field3
    hello,"1,2,3", bye

    BCP will see the second line as having 5 fields, not 2. I need it to import "1,2,3" as 1,2,3 not as 1 and 2 and 3.
    Greetz,

    Bastiaan Olij

  2. #2
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    Isn't it an idea to use a different field-delimiter and omit the "-character?

    If you use a semicolon instead of a comma the 1, 2, 3-sequence will be taken in as 1 field.

  3. #3
    Join Date
    Feb 2003
    Location
    Netherlands
    Posts
    63
    Martijn,

    That is what I would normally do but I get these files like this and excel screws up the data big time so I can't use it to convert the data to something usable.

    Offcourse I can make a little parser but if there is a way to do this directly with BCP.....
    Greetz,

    Bastiaan Olij

  4. #4
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524
    ... and using a bcp format file (option -f) ?

  5. #5
    Join Date
    Feb 2003
    Location
    Netherlands
    Posts
    63
    fadace,

    But how do I setup my format file to accurately recognise this situation? Can I define that it needs to ignore , as a delimiter if it is between quotes?

    I've only seen examples of it ignore " but then my ,'s will be seen as delimiters and screw up my import.

    But I am not very knowladgeable when it comes to format files..
    Greetz,

    Bastiaan Olij

  6. #6
    Join Date
    Aug 2009
    Posts
    1

    Sql

    BCP the file as a comma seperated file then update the raw table and replace the doubl quotes with nothing.

  7. #7
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1

Posting Permissions

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