From a Cloud Export database table to CSV format, found that the bigint field is also added double quotation marks, should not ah, how to remove it?
Example records:
"31189","aaaa","$P$BFMnptFob/7bmU2o***PNqorSMKzLs0","aaaa","aaa@qq.com","","2015-02-27 02:18:54","","0","oo","0000-00-00""31191","bbbb","$P$BeRmQEYPfnOfKrKpF***9osOe3v0aq/","bbb","bbb@qq.com","","2015-02-27 04:23:52","","0","bbb","0000-00-00"
Reply content:
From a Cloud Export database table to CSV format, found that the bigint field is also added double quotation marks, should not ah, how to remove it?
Example records:
"31189","aaaa","$P$BFMnptFob/7bmU2o***PNqorSMKzLs0","aaaa","aaa@qq.com","","2015-02-27 02:18:54","","0","oo","0000-00-00""31191","bbbb","$P$BeRmQEYPfnOfKrKpF***9osOe3v0aq/","bbb","bbb@qq.com","","2015-02-27 04:23:52","","0","bbb","0000-00-00"
Why get rid of PHP has corresponding function
Http://php.net/str_getcsv
Leon, we've got a PHP version of the deal.
function Fucking_aliyun_rds ($line) {
if(!$line) return; $line=(string)$line; $pattern='/^\"\d{1,5}\"/'; $int=$replacement=false; if(preg_match($pattern, $line, $matches)){ $int=(int)str_replace('"', '', $matches[0]); }else{ return $line; } if($int){ $replacement = $int; $line=preg_replace('""', '',$line); $b=preg_replace($pattern, $replacement, $line); } $b.="\t"; return $b;
}
$f = fopen ("Wp_users.txt", "R");
$LN = 0;
while (! feof ($f)) {
$line = fgets ($f);
/* + + $LN; /
/printf ($LN); */
if ($line ===false) {
}
else{
$a=fucking_aliyun_rds($line); echo $a;}
}
Fclose ($f);