Bug 36831: Allow for multiple file types
This patch allows the KBART import tool to accept different filetypes and then work out whether they are CSV or TSV files. Test plan: 1) Try to import the file attached to the bug using the KBART import tool (E-resource management > eHoldings > Local > Titles > Import from a KBART file) 2) It should return an error saying that the file must be .csv or .tsv 3) Apply patch 4) yarn build 5) restart_all 6) Repeat step 1 7) The file should now successfully import Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
2fac8ba451
commit
41e198bfcd
|
|
@ -140,7 +140,7 @@ sub read_file {
|
|||
return ( $column_headers, $lines, $error );
|
||||
}
|
||||
|
||||
return ( $column_headers, $lines );
|
||||
return ( $column_headers, $lines, '' );
|
||||
}
|
||||
|
||||
=head3 get_valid_headers
|
||||
|
|
@ -262,7 +262,7 @@ sub _detect_delimiter_and_quote {
|
|||
my %quote_count;
|
||||
|
||||
foreach my $line (@lines) {
|
||||
foreach my $char ( ',', '\t', ';', '|' ) {
|
||||
foreach my $char ( ",", "\t", ";", "|" ) {
|
||||
my $count = () = $line =~ /\Q$char\E/g;
|
||||
$delimiter_count{$char} += $count if $count;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,21 +2,6 @@
|
|||
<h2>{{ $__("Import from a KBART file") }}</h2>
|
||||
<div class="page-section" id="files">
|
||||
<form @submit="addDocument($event)" class="file_upload">
|
||||
<h3>{{ $__("Requirements:") }}</h3>
|
||||
<ul style="margin-bottom: 1.5em">
|
||||
<li>{{ $__("The file must be in TSV or CSV format") }}</li>
|
||||
<li>
|
||||
{{
|
||||
$__(
|
||||
"The file should not contain any additional information / header rows, e.g. a file with a single title would be structured as follows:"
|
||||
)
|
||||
}}
|
||||
<ol>
|
||||
<li>{{ $__("Column headings row") }}</li>
|
||||
<li>{{ $__("Title data row") }}</li>
|
||||
</ol>
|
||||
</li>
|
||||
</ul>
|
||||
<fieldset class="rows" id="package_list">
|
||||
<h3>{{ $__("Select file for upload") }}:</h3>
|
||||
<ol>
|
||||
|
|
@ -174,7 +159,7 @@ export default {
|
|||
}
|
||||
if (success.warnings.invalid_filetype) {
|
||||
message += `<p>${this.$__(
|
||||
"The file must be in .tsv or .csv format, please convert your file and try again."
|
||||
"Could not detect whether the file is TSV or CSV, please check the file."
|
||||
)}</p>`;
|
||||
this.setWarning(message);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue