03-22-2024, 07:48 PM | #661 |
Custom User Title
Posts: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
format_date and partial dates
I'm using this template to display a list of dates formatted as 'yyyy-MM-dd' as 'MMM d yyyy': Code:
program: new_dates = ''; for dates in '#datesread': converted = format_date(dates, 'MMM d yyyy'); new_dates = list_union(new_dates, converted, ',') rof What should I do here to get '2017, Jun 13 2023'? Alternately, I'd be fine removing the partial dates. Last edited by ownedbycats; 03-22-2024 at 10:04 PM. |
03-23-2024, 09:20 AM | #662 | |
Grand Sorcerer
Posts: 11,789
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
You don't say if you can have a date like '2020-05'. Assuming you can, a variation of this template might give you what you want. Code:
program: new_dates = ''; for dates in '2020, 2021-05, 2022-03-10': if list_count(dates,'-') ==# 3 then converted = format_date(dates, 'MMM d yyyy') elif '-' in dates then converted = re(format_date(dates, 'MMM d yyyy'), ' 15 ', ' ') else converted = dates fi; new_dates = list_union(new_dates, converted, ',') rof Code:
Mar 10 2022, May 2021, 2020 |
|
Advert | |
|
03-23-2024, 01:20 PM | #663 |
Custom User Title
Posts: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
I have only yyyy and yyyy-mm-dd, but that template worked on all the books I tested.
I didn't think of using a list_count with a - separator. |
05-11-2024, 08:37 PM | #664 |
Guru
Posts: 734
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
|
A template has stopped working.
I was using the formula from this thread https://www.mobileread.com/forums/sh...&postcount=574 Code:
python: def evaluate(book, context): vals = context.funcs.book_values('#ranking', 'title:true', '&', 0).split('&') vals = sorted([float(v) for v in vals], reverse=True) return str(1 + vals.index(float(book.get('#ranking')))) to calculate the ranking position and now it says that there is an error on line 4 Give me a hand with the solution |
05-11-2024, 08:40 PM | #665 | |
Grand Sorcerer
Posts: 11,789
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Edit: an error will be thrown if #ranking contains something that isn't a number Last edited by chaley; 05-11-2024 at 08:44 PM. |
|
Advert | |
|
05-11-2024, 09:13 PM | #666 | |
Guru
Posts: 734
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
|
Quote:
The personal column #grecuento and the template Last edited by dunhill; 05-11-2024 at 09:15 PM. |
|
05-12-2024, 12:57 AM | #667 |
Grand Sorcerer
Posts: 11,789
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
05-12-2024, 09:14 AM | #668 |
Junior Member
Posts: 1
Karma: 10
Join Date: Sep 2020
Device: Fire 7
|
Hi, everyone!
I'm a total noob but I want to make a template for a composite column that takes the number of Goodreads' votes in the #grvotes column and adds 'thousand separators' to them, so that, for example, instead of 1678234 it shows 1,678,234. I've been trying this Code:
{#grvotes:format_number({0:#,##})} Could you help me? |
05-12-2024, 12:23 PM | #669 | |
Guru
Posts: 734
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
|
Quote:
The real error is described in the first image: Exception:Error in function <listcomp> on line 4: ValueError could not convert string to float: " The strange thing is that it used to work fine. I really don't know what happened but it was solved by redownloading or updating metadata, I was really worried. As always, I appreciate the help always received. Last edited by dunhill; 05-12-2024 at 12:46 PM. |
|
05-12-2024, 01:03 PM | #670 | |
Grand Sorcerer
Posts: 11,789
Karma: 7029971
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
And you are welcome. |
|
05-12-2024, 03:31 PM | #671 | |
Guru
Posts: 734
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
|
Quote:
I appreciate your offer, but I wouldn't want to waste your time. When uploading a new book to my personal library of almost 500 books. I usually load everything that depends on a template. The error may have been that I accidentally deleted a value, leaving it at zero or without data. Last edited by dunhill; 05-12-2024 at 03:34 PM. |
|
05-16-2024, 09:01 AM | #672 |
Junior Member
Posts: 2
Karma: 10
Join Date: May 2024
Device: Kobo Libra 2
|
Dozens of TypeError popups when searching for books in "get books"
Hi, sorry if this is the wrong place to post, I've searched in the forum for a bit and couldn't find something regarding this specific problem I have.
Whenever I open the get books section and search for books using a keyword, I get a lot of pop-ups displaying the following error message: Code:
calibre, version 6.13.0 ERROR: Unhandled exception: <b>TypeError</b>:expected string or bytes-like object, got 'NoneType' calibre 6.13 embedded-python: False Linux-6.1.0-20-amd64-x86_64-with-glibc2.36 Linux ('64bit', 'ELF') ('Linux', '6.1.0-20-amd64', '#1 SMP PREEMPT_DYNAMIC Debian 6.1.85-1 (2024-04-11)') Python 3.11.2 Interface language: None Traceback (most recent call last): File "/usr/lib/calibre/calibre/gui2/store/search/search.py", line 387, in get_results self.results_view.model().add_result(res, store_plugin) File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 97, in add_result self._filter_results() File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 119, in _filter_results self.sort(self.sort_col, self.sort_order, False) File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 291, in sort self.all_matches.sort( File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 292, in <lambda> key=lambda x: sort_key(str(self.data_as_text(x, col))), ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 263, in data_as_text text = comparable_price(result.price) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/calibre/calibre/gui2/store/search/models.py", line 24, in comparable_price match = re.search(r'(?:\d|[,.](?=\d))(?:\d*(?:[,.\' ](?=\d))?)+', text) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/lib/python3.11/re/__init__.py", line 176, in search return _compile(pattern, flags).search(string) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: expected string or bytes-like object, got 'NoneType' Thanks a lot in advance and please remove this post in case it is a duplicate or in the wrong place. |
05-16-2024, 09:21 AM | #673 |
creator of calibre
Posts: 44,019
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
You are using a distro package uninstall and install the official calibre binaries and you should be fine.
|
05-16-2024, 09:57 AM | #674 |
Junior Member
Posts: 2
Karma: 10
Join Date: May 2024
Device: Kobo Libra 2
|
|
05-16-2024, 07:26 PM | #675 |
Custom User Title
Posts: 8,841
Karma: 62032373
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
|
For an Action Chains copy-to-clipboard, how do I insert a line break into a strcat?
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Library Management: various questions not worth their own thread | ownedbycats | Library Management | 153 | 05-14-2024 01:30 AM |
[Metadata Source Plugin] Questions regarding parse select, docs and ref templates | Boilerplate4U | Development | 13 | 07-07-2020 02:35 AM |
Questions on Kobo [Interfered with another thread topic] | spdavies | Kobo Reader | 8 | 10-12-2014 11:37 AM |
[OLD Thread] Some questions before buying the fire. | darthreader13 | Kindle Fire | 7 | 05-10-2013 09:19 PM |
Thread management questions | meme | Feedback | 6 | 01-31-2011 05:07 PM |