Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bibx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"read_wos",
]

__version__ = "0.6.0"
__version__ = "0.6.1"


def query_openalex(
Expand Down
8 changes: 4 additions & 4 deletions src/bibx/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ def permalink(self) -> Optional[str]:
@property
def simple_id(self) -> Optional[str]:
"""Return a simple ID for the article."""
if self.authors and self.year is not None:
author = self.authors[0].split(" ")[0].replace(",", "")
return f"{author}{self.year}".lower()
return None
if not self.authors or self.year is None:
return None
author = self.authors[0].split(" ")[0].replace(",", "")
return f"{author}{self.year}".lower()

def __repr__(self) -> str:
"""Return a string representation of the article."""
Expand Down
9 changes: 9 additions & 0 deletions src/bibx/builders/scopus_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ def _parse_file(self, file: TextIO) -> Generator[Article]:
reader = csv.DictReader(file)
for row in reader:
datum = Row.model_validate(row)
if not datum.authors or not datum.year:
logger.info(
"skipping row with missing authors or year: %s",
datum.model_dump_json(indent=2),
)
continue
yield (
Article(
label="",
Expand Down Expand Up @@ -131,6 +137,9 @@ def _parse_file(self, file: TextIO) -> Generator[Article]:
def _article_from_reference(self, reference: str) -> Optional[Article]:
try:
*authors, journal, issue, year = reference.split(", ")
if not authors:
message = "a minimum of one author is required"
raise ValueError(message)
_year = int(year.lstrip("(").rstrip(")"))
return Article(
label=reference,
Expand Down