add funtion after replace -"new line"

Bug #1770751 reported by Robin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
calibre
Fix Released
Undecided
Charles Haley

Bug Description

An option that would be nice if someone is moving long text to long text but doesn't want to break it up. Or instead of add function, apply it in the append, replace or prepend option.

Robin (robin-ellwood)
summary: - add funtion after replace "new line"
+ add funtion after replace -"new line"
description: updated
Revision history for this message
Kovid Goyal (kovid) wrote : Re: calibre bug 1770751

Changing the component for this bug.

 assignee cbhaley
 status triaged

Changed in calibre:
assignee: nobody → Charles Haley (cbhaley)
status: New → Triaged
Revision history for this message
Charles Haley (cbhaley) wrote :

Sorry, but I don't understand what you want to do. If you want to append the new text to the existing text then prepend a newline to the replace expression and use "append".

Changed in calibre:
status: Triaged → Fix Committed
Revision history for this message
Robin (robin-ellwood) wrote : Re: [Bug 1770751] Re: add funtion after replace -"new line"
Download full text (3.3 KiB)

Hi, Sorry it took so long, but I missed this email.

Regarding what I meant when I asked for a "new line" when copy/replacing
long text to long text.

Imaging having multiple long text custom columns, and for whatever reason
you want to copy one column into another. You do not want to break up the
data, since it is long text and not comma separated, Also in the copy to
column, you do not want to replace the current data, but add the first
column data after (append).

Right now you have the ability to copy a long text column to a comma
separated column and break up each word using the spaces as the breaking
points. However if you are not interested in breaking up the long text
(maybe you are copying different folder locations or file names, or long
dates) If you do not want to replace the current values, and do not want to
break up the values being copied, you have only the option to have a single
comma separate the two (or more) values.

This makes the column data messy because it simply loops one long set of
data only using a comma to separate the values. If a person wanted to
compare the data against itself, or edit the values it is very difficult.
If the data already contains a comma then it is very difficult to determine
the beginning and end points.

I am proposing that the append pr prepend feature include the option to add
a paragraph or line break function. so that the appended information is set
under the current and looks nicer in the column, is easier to read and
compare with information above, or below it, and finally doesn't mix up the
commas currently being used in the data.

I am always importing dates into columns, but each column is copied into a
long text column so that I can empty out the first one and reuse it again
for newer data. The long text columns often are used as a dumping ground
for multiple values of the same column via copy/replace. I would find that
having the ability to include the new line function would make it easier to
see the data in a straight line down the column instead of trying to read
it word wise, hunting for the comma that isn't even a comma-space.

Column 1 plain long text: Book NAME one.azw3
Column 2 plain long text: booknametwo.epub
Column 3 plain long text: Book, Series 3.epub

Copy all to column 3

Curent results of copy to column:
Book NAME one.azw3,booknametwo.epub,Book, Series 3,epub

Proposed changes:
Book Name one.azw3
booknametwo.epub
Book, Series 3.epub

On Tue, May 15, 2018 at 1:30 PM, Charles Haley <email address hidden>
wrote:

> Sorry, but I don't understand what you want to do. If you want to append
> the new text to the existing text then prepend a newline to the replace
> expression and use "append".
>
> ** Changed in: calibre
> Status: Triaged => Fix Committed
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1770751
>
> Title:
> add funtion after replace -"new line"
>
> Status in calibre:
> Fix Committed
>
> Bug description:
> An option that would be nice if someone is moving long text to long
> text but doesn't want to break it up. Or instead of add function,
> apply...

Read more...

Revision history for this message
Charles Haley (cbhaley) wrote :

You can already do what you want, but before I go there ...

Why do you say that you can only convert long text to comma-separated text? You can copy long text columns verbatim. If you are using append or prepend then you must uncheck the "Split result" box to tell calibre not to separate the fields with a comma.

There are two ways to do what you want, one using "prepend" and one using templates. When using "prepend" you combine two fields together with a newline (\n) between them. You can also use "append" but then you must move the \n to the other side of the replacement expression. See the attached screen capture "prepend_mode".

You can also use a template to construct the result however you want, combining whatever fields you want. In this case you use "Replace", use a placeholder in the template for the newline, and use the replacement expression to replace the placeholder with a real newline. See the attached screen capture "template_mode". The template is not readable in the image so here it is:
program: strcat(field('#comment2'), 'XYX', field('#comment3'), 'XYX', field('#comment'))

Do note that this technique won't work well with HTML comments. One would need to pick the HTML apart then reconstruct it.

Revision history for this message
Charles Haley (cbhaley) wrote :
Revision history for this message
Robin (robin-ellwood) wrote :

I think I may have misstated what I meant by splitting the result. I was thinking that if the long text was split that for whatever reason the spaces would be the splitting locations.

Long text to be copied to another long text.ebook would turn into
Long,text,to,be,copied,to,another,long,text.ebook,

Sorry. I know that it takes commas to indicate the splits in text (although if there already is commas in the long text - say in a review- then the delineation of a comma splitting the appended long text would be weirdly formatted.

Thanks for the plugin/template information. It doesn't help in my case since I don't understand how to create the templates in the first place. You guys did a lot to try and teach the average user how to create functions and templates, but some of us just don't get it, or want to try and make something that would take a long time to get right, and then worry about ruining a library if it is wrong.

I'll figure it out. I just wanted to see that the /n function be available in the copy/paste command.
Thanks!

Revision history for this message
Charles Haley (cbhaley) wrote :

The prepend_mode.jpg screen capture does what you want without using templates. It inserts the source long text column followed by a newline into the destination long text column. The S&R append_mode.jpg screen capture below does the opposite, appending a newline and the source long text to the destination long text column.

Revision history for this message
Robin (robin-ellwood) wrote :

Thanks!

On Fri, Jun 1, 2018 at 1:21 AM Charles Haley <email address hidden>
wrote:

> The prepend_mode.jpg screen capture does what you want without using
> templates. It inserts the source long text column followed by a newline
> into the destination long text column. The S&R append_mode.jpg screen
> capture below does the opposite, appending a newline and the source long
> text to the destination long text column.
>
> ** Attachment added: "append_mode.jpg"
>
> https://bugs.launchpad.net/calibre/+bug/1770751/+attachment/5147311/+files/append_mode.jpg
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1770751
>
> Title:
> add funtion after replace -"new line"
>
> Status in calibre:
> Fix Committed
>
> Bug description:
> An option that would be nice if someone is moving long text to long
> text but doesn't want to break it up. Or instead of add function,
> apply it in the append, replace or prepend option.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/calibre/+bug/1770751/+subscriptions
>

Charles Haley (cbhaley)
Changed in calibre:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.