Bugzilla – Attachment 5057 Details for
Bug 6727
can't import frameworks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Proposed patch with changes on exporting and importing csv to deal with spurious CR/LF
0001-Bug-6727-Change-on-exporting-and-importing-csv-to-de.patch (text/plain), 2.11 KB, created by
Salva Zaragoza Rubio
on 2011-08-19 10:43:07 UTC
(
hide
)
Description:
Proposed patch with changes on exporting and importing csv to deal with spurious CR/LF
Filename:
MIME Type:
Creator:
Salva Zaragoza Rubio
Created:
2011-08-19 10:43:07 UTC
Size:
2.11 KB
patch
obsolete
>From 872ae4e39474bff92e7f81fb3d538d013ec8c614 Mon Sep 17 00:00:00 2001 >From: Salvador Zaragoza Rubio <salvazm@masmedios.com> >Date: Fri, 19 Aug 2011 12:33:05 +0200 >Subject: [PATCH] Bug 6727 - Change on exporting and importing csv to deal with spurious CR/LF >Content-Type: text/plain; charset="utf-8" > >Function _export_table_csv modified to remove CR/LF in the data >from the database to built a correct csv file. > >Function _import_table_csv modified to deal with CR/LF in the data >field. When a line is found with an unproper end (a data field has not >end quote), it's concatenated to a temporary buffer until the next >line ends ok and then it's proccessed. >--- > C4/ImportExportFramework.pm | 13 +++++++++++++ > 1 files changed, 13 insertions(+), 0 deletions(-) > >diff --git a/C4/ImportExportFramework.pm b/C4/ImportExportFramework.pm >index 7f29e51..e518771 100755 >--- a/C4/ImportExportFramework.pm >+++ b/C4/ImportExportFramework.pm >@@ -322,6 +322,7 @@ sub _export_table_csv > my $data; > while (my $hashRef = $sth->fetchrow_hashref) { > for (@fields) { >+ $hashRef->{$_} =~ s/[\r\n]//g; > $$strCSV .= '"' . $hashRef->{$_} . '",'; > } > chop $$strCSV; >@@ -1133,6 +1134,7 @@ sub _import_table_csv > my ($dbh, $table, $frameworkcode, $dom, $PKArray, $fields2Delete, $fields) = @_; > > my $row = ''; >+ my $partialRow = ''; > my $numFields = @$fields; > my $fieldsNameRead = 0; > my @arrData; >@@ -1145,6 +1147,17 @@ sub _import_table_csv > my $pos = 0; > while (<$dom>) { > $row = $_; >+ # Check whether the line has an unfinished field, i.e., a field with CR/LF in its data >+ if ($row =~ /,"[^"]*[\r\n]+$/ || $row =~ /^[^"]+[\r\n]+$/) { >+ $row =~ s/[\r\n]+$//; >+ $partialRow .= $row; >+ next; >+ } >+ if ($partialRow) { >+ $row = $partialRow . $row; >+ $partialRow = ''; >+ } >+ # Line OK, process it > if ($row =~ /(?:".*?",?)+/) { > @arrData = split('","', $row); > $arrData[0] = substr($arrData[0], 1) if ($arrData[0] =~ /^"/); >-- >1.7.3.5 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 6727
:
5030
|
5042
|
5043
|
5044
|
5057
|
5134