На самом деле у вас есть неверно сформированные данные CSV, где символ разделителя равен |
.
Это неправильно сформировано, потому что "внутренние" кавычки не экранированы: в CSV-поле, которое содержит кавычки, кавычки должны быть продублированы, как это
1,2,"field,with,commas","this field ""contains quotes"" that are duplicated"
# ..................................^^...............^^
Если возможно исправить ваши входные данные, чтобы они выглядели так:
"Live Your Dreams: Be You"|"20 Feb 2018"|"2 formats and editions"|"Are you being swept away by life being busy? Are things seemingly out of your control? Do you want to calm the chaos in your life? Are you ready to transform your life? In
""Live Your Dreams""
now AMAZON BESTSELLER, readers are shown how to take immediate control of their mental, emotional, physical and entrepreneurial destiny."|"All this and more as you immerse yourself in the story that opens up like scenes from ""a Bollywood movie"""|"Indian Edition"
если внутренние кавычки в строках 2 и 3 правильно экранированы, то вы можете использовать анализатор CSV для преобразования выходных кавычек. Синтаксический анализатор Perl csv может обрабатывать поля, содержащие символы новой строки:
perl -MText::CSV -e '
open my $fh, "<:encoding(UTF-8)", shift(@ARGV);
my $csv_in = Text::CSV->new({ quote_char => "\"", sep_char => "|", binary => 1 });
my $csv_out = Text::CSV->new({ quote_char => "~", escape_char => "~", sep => "|", binary => 1 });
while (my $row = $csv_in->getline($fh)) {
$csv_out->say(STDOUT, $row);
}
$csv_in->eof or $csv_in->error_diag();
' file.csv
~Live Your Dreams: Be You~|~20 Feb 2018~|~2 formats and editions~|~Are you being swept away by life being busy? Are things seemingly out of your control? Do you want to calm the chaos in your life? Are you ready to transform your life? In
"Live Your Dreams"
now AMAZON BESTSELLER, readers are shown how to take immediate control of their mental, emotional, physical and entrepreneurial destiny.~|~All this and more as you immerse yourself in the story that opens up like scenes from "a Bollywood movie"~|~Indian Edition~