If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Perl and the DBI > DBI, CSV, quotes for text remain intake

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-12-07, 17:14
PistolPete PistolPete is offline
Registered User
 
Join Date: Feb 2007
Posts: 1
DBI, CSV, quotes for text remain intake

How do I make sure the quotes are text remain intact? for example
id,text
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);
$sth->execute();
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);
Reply With Quote
  #2 (permalink)  
Old 03-04-07, 16:24
sco08y sco08y is offline
Registered User
 
Join Date: Oct 2002
Location: Baghdad, Iraq
Posts: 697
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: http://search.cpan.org/~jzucker/DBD-...lib/DBD/CSV.pm

Also, this kills me:

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

Code:
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...)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On