The scripts available here will calculate the number of digitized newspaper issues available year by year, state by state in Chronicling America, the Library of Congress’ database of historic American newspapers.
Each script is named “state_issues_year_2019_[state_abbreviation]” and will create a .csv file of the number of digitized issues available in Chronicling America for each year of digitized content from state partners that is available.
Please visit https://chroniclingamerica.loc.gov/about/api/ for background information about the various views of data available from Chronicling America.
state_issues_year_2019_DC.py or other files with state/territory abbreviationsThe output from this script is one .csv file named "District of Columbia_total.csv". Each row in the .csv contains the state name, year, and number of issues available in Chronicling America.
state_issues_year_2019_NOSTATEUse find and replace for "STATE_NAME" with the state or territory name you want the script run for. The output from this script is one .csv file named "STATE_NAME_total.csv". Each row in the .csv contains the state name, year, and number of issues available in Chronicling America.
To run this script, you'll need to have Python 3 installed. You will also need access to a command line interface such as Terminal on OS X, Anaconda on Windows, or other.
Save the "state_issues_year_2019_[state_abbreviation]" file to a folder where you want the results file saved. Using the command line interface, navigate to the folder.
Run the script by typing: "python state_issues_year_2019_[state_abbreviation]"
Ex: python state_issues_year_2019_DC.py
There is no indication printed to the console that the script is running. When the script is complete, "done" will be printed to the console.
The scripts can be changed to run for any state. The template file is state_issues_year_2019_NOSTATE.py. To change the states issues being counted, use find for "NO STATE" and replace for the state or territory name you would like the script run on. There is an issue count script for each state and territory available in Chronicling America as of May 2019. As additional content from new state partners is added to Chronicling America, the state_issues_year_2019_NOSTATE.py file can be updated to add the state information by using find "STATE_NAME" and replace with the state/territory you would like to add.
We used this script to pull data from Chronicling America to create data visualizations available at http://www.loc.gov/ndnp/data-visualizations/.
Please provide any feedback you may have by filing an issue.
If you use this script, please let us know at LC Labs or [email protected].
For additional information about accessing the Library of Congress’ collections programmatically please visit LC for Robots.
Script is free to use and reuse without restriction.