Skip to main content

PyPI version

COVID-19 Data Tools

Tools for making COVID 19 data slightly easier for everyone! If you A) think something would be useful in your research or B) have some helpful code to contribute, make an issue or PR ASAP so we can get your code shared!

Installation

pip install cord-19-tools

BE SURE TO HAVE THE MOST RECENT VERSION! I will be constantly updating to make sure users are getting the right data! Semantic Scholar updates the dataset every friday, so on fridays and saturdays be sure to redownload data!

Demo

Demonstration Notebook on colab

Downloading the data

To download and extract the data, use the download function:

import cotools
from pprint import pprint

cotools.download()

For now this just downloads the data from the CORD-19 dataset, metadata is not included (will be by end of day), extracts all the tarfiles, and places them in a directory

The Paperset class

This is a class for lazily loading papers from the CORD-19 dataset.

# no `/` at the end please!
data = cotools.Paperset("data/comm_use_subset")

# indexes with ints
pprint(data[0])
# returns a dict

# and slices!
pprint(data[:2])
# returns a list of dicts


print(len(data))

# takes about 5gb in memory
alldata = data[:]

Lets talk for a bit about how it works, and why it doesnt take a gigantic amount of memory. The files are not actually loaded into python until the data is indexed. Upon indexing, the files at those indexes are read into python, resulting in a list of dictionaries. This means you can still contribute while working on a low resource system.

Getting text and abstracts

For text, there is the text function, which returns the text from a single document, the texts function, which returns the text from multiple documents, and the Paperset.texts() function, which gets the text from all documents:

print(cotools.text(data[0]))
print(cotools.texts(data[12:18]))

alltext = data.texts()
# alltext = cotools.texts(alldata)

For abstracts, we have a similar API:

print(cotools.abstract(data[0]))
print(cotools.abstracts(data[12:18]))

allabs = data.abstracts()
# allabs = cotools.abstracts(alldata)

Manipulating

You can also manipulate the documents with the Paperset.apply method:

keys = comm_use.apply(lambda x: list(x.keys()))
# then lets combine them into a set
print(set(sum(keys, [])))

Searching

You can search with a list OR a nested list! See the demo notebook for more examples!

txt = [["covid", "novel coronavirus"], ["ventilator", "cpap", "bipap"]]

x = cotools.search(comm_use, txt)
print(len(x))
print(len(cotools.search(comm_use, txt[0])))
print(len(cotools.search(comm_use, txt[-1])))

TODO

Release files for cord-19-tools 0.3.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cord-19-tools 0.3.3
File Size Uploaded
cord-19-tools-0.3.3.tar.gz 2.4 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for cord-19-tools 0.3.3
File Interpreter ABI Platform
cord_19_tools-0.3.3-py3-none-any.whl Python 3 none any Details

Total release size: 2.4 MB

Release files / cord-19-tools-0.3.3.tar.gz

Download URL cord-19-tools-0.3.3.tar.gz
Size 2.4 MB
Tags Source
SHA-256 checksum
How to use checksums
7010870a1a81c8bd360958a7c89055b9e81e01e4b3c4d422163d0455a16eb586
BLAKE2b-256 checksum
How to use checksums
28d5c32b4d14e7b71c92bd6d1a69b45cf5f2dd0cf82e7130dd887d3985cda102
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200310 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release files / cord_19_tools-0.3.3-py3-none-any.whl

Download URL cord_19_tools-0.3.3-py3-none-any.whl
Size 8.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
35ebcb25417ebf0b3474eb21a29b512644afa5ec33bdb1ebf2e25f77472ea401
BLAKE2b-256 checksum
How to use checksums
6739ae66d70ca6fc670ac0b6d622d850e44dbf028c91ec22d739c3d3d36fcf4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0.post20200310 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 release files

0.3.2

2 release files

0.3.0

2 release files

0.2.8

2 release files

0.2.7

2 release files

0.2.5

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page