Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2007

    Unanswered: DBI, CSV, quotes for text remain intake

    How do I make sure the quotes are text remain intact? for example
    2, "jones runs"
    1, "edison jumps"

    doesn't become
    1, edison jumps
    2, jones runs
    Here is some of my code if that helps.

    $dbh->{'csv_tables'}->{'cc'}= {
    'eol' => "\n",
    'sep_char' => "|",
    'quote_char' => undef,
    'escape_char' => undef,
    'file' => $outputfile,
    'col_names' => ["Module", "Baseline", "ObjectID", "AbsNum", "Date", "Author", "Action",
    "AttrName", "Old_Value", "New_Value","Attr_CPStatus", "Attr_CPtype",
    "Attr_CPaction", "Attr_CPtarget", "Attr_WSTR_Number", "Attr_LastModifiedOn",
    "Attr_Req", "Attr_ReqEDM", "Attr_ReqFlt", "Attr_Classification",
    "Attr_isDeleted", "ModuleFullName"]};

    my($query) = "SELECT cc.Module, cc.Baseline, cc.ObjectID, cc.AbsNum, cc.Date, cc.Author,
    cc.Action, cc.AttrName, cc.Old_Value, cc.New_Value, cc.Attr_CPStatus,
    cc.Attr_CPtype, cc.Attr_CPaction, cc.Attr_CPtarget, cc.Attr_WSTR_Number,
    cc.Attr_LastModifiedOn, cc.Attr_Req, cc.Attr_ReqEDM, cc.Attr_ReqFlt,
    cc.Attr_Classification, cc.Attr_isDeleted, cc.ModuleFullName
    FROM cc ORDER BY cc.Date, cc.Action";
    # What we want is to update this file where A.Folder =B.Folder and B.Project ='2'
    #If Folder is not a number then error

    my($sth) = $dbh->prepare($query);
    my($mod,$bln,$ob,$abs,$dt,$au,$act,$an,$ov,$nv,$ac ps,$acpt, $acpa,$acpt,$ws,$almo,$ar,$are,$arf,$ac,$aid,$mfn) ;
    $sth->bind_columns(undef,\$mod,\$bln,\$ob,\$abs,\$dt,\$ au,\$act,\$an,\$ov,
    \$nv,\$acps,\$acpt,\$acpa,\$acpt,\$ws,\$almo,\$ar, \$are,\$arf,\$ac,\$aid,\$mfn);

  2. #2
    Join Date
    Oct 2002
    Baghdad, Iraq
    It's probably throwing out the quotes becaues quote_char is set to undef. Instead of copying and pasting random code off the web, try going to the source:

    Also, this kills me:

    my($mod, $bin, $ob...)
    bind(undef, \$mod,\$bln,\$ob,...)
    Try this instead:

    bind(undef, \(my($mod, $bin, ...)))
    Basically, using \ on a list of variables gives you a list of references to those variables. And since my returns a perfectly good list of variables, no need to type everything twice. (Oh, and Perl flattens lists which is how you can stick undef in there...)

Posting Permissions

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