View Single Post
Old 12-30-2022, 08:01 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,451
Karma: 8012886
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by DBorG View Post
I created custom column "Comic Staff" from different custom columns "Comic Inker", "Comic Letterer", "Comic Editor" etc.
I use this template for creation of column:

{#com_inker:|(inker) |, }{#com_letterer:|(letterer) |, }{#com_colorist:|(colorist) |, }{#com_editor:|(editor) |, }{#com_cover_artist:|(cover artist) |, }

but in columns view it shows ", " at the beginning:

, (colorist) name of Colorist, (cover artist) name of Cover Artist, (editor) name of Comic Editor, (inker) name of Inker, (letterer) name of Letterer

how to get rid of that column+space at beginning?

I know that it sorts alphabetically, and if i remove "," from Comic Colorist it will lose ", " on beginnings, but if next comic doesn't have colorist it will again show it at beginning for Cover artist.

Its a small thing but it bugs me.

Thanks in advance
Your problem: you are constructing a list where there is always a comma at the end. This tells calibre to add an empty item to the list. You need to remove the last comma, which is made more complicated by the fact that not all the referenced columns have values so you can't know in advance which comma to remove.

There are several ways to do the job, but I think this General Program Mode template is the easiest to understand. It first generates the same value as your template then uses the re() function to remove the trailing comma. Note that the re() searches for comma, not comma-space. This is required because leading and trailing spaces are removed by template().
Code:
program:
	v = template('{#com_inker:|(inker) |, }{#com_letterer:|(letterer) |, }{#com_colorist:|(colorist) |, }{#com_editor:|(editor) |, }{#com_cover_artist:|(cover artist) |, }');
	re(v, ',$', '')
chaley is offline   Reply With Quote