Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collapse and add argparse #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
346 changes: 346 additions & 0 deletions chronam_issue_counts/ISO_3166-2:US.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,346 @@
{
"ISO_3166-2:US": [
{
"code": "US-AL",
"short_code": "AL",
"subdivision_name": "Alabama",
"subdivision_category": "state"
},
{
"code": "US-AK",
"short_code": "AK",
"subdivision_name": "Alaska",
"subdivision_category": "state"
},
{
"code": "US-AZ",
"short_code": "AZ",
"subdivision_name": "Arizona",
"subdivision_category": "state"
},
{
"code": "US-AR",
"short_code": "AR",
"subdivision_name": "Arkansas",
"subdivision_category": "state"
},
{
"code": "US-CA",
"short_code": "CA",
"subdivision_name": "California",
"subdivision_category": "state"
},
{
"code": "US-CO",
"short_code": "CO",
"subdivision_name": "Colorado",
"subdivision_category": "state"
},
{
"code": "US-CT",
"short_code": "CT",
"subdivision_name": "Connecticut",
"subdivision_category": "state"
},
{
"code": "US-DE",
"short_code": "DE",
"subdivision_name": "Delaware",
"subdivision_category": "state"
},
{
"code": "US-FL",
"short_code": "FL",
"subdivision_name": "Florida",
"subdivision_category": "state"
},
{
"code": "US-GA",
"short_code": "GA",
"subdivision_name": "Georgia",
"subdivision_category": "state"
},
{
"code": "US-HI",
"short_code": "HI",
"subdivision_name": "Hawaii",
"subdivision_category": "state"
},
{
"code": "US-ID",
"short_code": "ID",
"subdivision_name": "Idaho",
"subdivision_category": "state"
},
{
"code": "US-IL",
"short_code": "IL",
"subdivision_name": "Illinois",
"subdivision_category": "state"
},
{
"code": "US-IN",
"short_code": "IN",
"subdivision_name": "Indiana",
"subdivision_category": "state"
},
{
"code": "US-IA",
"short_code": "IA",
"subdivision_name": "Iowa",
"subdivision_category": "state"
},
{
"code": "US-KS",
"short_code": "KS",
"subdivision_name": "Kansas",
"subdivision_category": "state"
},
{
"code": "US-KY",
"short_code": "KY",
"subdivision_name": "Kentucky",
"subdivision_category": "state"
},
{
"code": "US-LA",
"short_code": "LA",
"subdivision_name": "Louisiana",
"subdivision_category": "state"
},
{
"code": "US-ME",
"short_code": "ME",
"subdivision_name": "Maine",
"subdivision_category": "state"
},
{
"code": "US-MD",
"short_code": "MD",
"subdivision_name": "Maryland",
"subdivision_category": "state"
},
{
"code": "US-MA",
"short_code": "MA",
"subdivision_name": "Massachusetts",
"subdivision_category": "state"
},
{
"code": "US-MI",
"short_code": "MI",
"subdivision_name": "Michigan",
"subdivision_category": "state"
},
{
"code": "US-MN",
"short_code": "MN",
"subdivision_name": "Minnesota",
"subdivision_category": "state"
},
{
"code": "US-MS",
"short_code": "MS",
"subdivision_name": "Mississippi",
"subdivision_category": "state"
},
{
"code": "US-MO",
"short_code": "MO",
"subdivision_name": "Missouri",
"subdivision_category": "state"
},
{
"code": "US-MT",
"short_code": "MT",
"subdivision_name": "Montana",
"subdivision_category": "state"
},
{
"code": "US-NE",
"short_code": "NE",
"subdivision_name": "Nebraska",
"subdivision_category": "state"
},
{
"code": "US-NV",
"short_code": "NV",
"subdivision_name": "Nevada",
"subdivision_category": "state"
},
{
"code": "US-NH",
"short_code": "NH",
"subdivision_name": "New Hampshire",
"subdivision_category": "state"
},
{
"code": "US-NJ",
"short_code": "NJ",
"subdivision_name": "New Jersey",
"subdivision_category": "state"
},
{
"code": "US-NM",
"short_code": "NM",
"subdivision_name": "New Mexico",
"subdivision_category": "state"
},
{
"code": "US-NY",
"short_code": "NY",
"subdivision_name": "New York",
"subdivision_category": "state"
},
{
"code": "US-NC",
"short_code": "NC",
"subdivision_name": "North Carolina",
"subdivision_category": "state"
},
{
"code": "US-ND",
"short_code": "ND",
"subdivision_name": "North Dakota",
"subdivision_category": "state"
},
{
"code": "US-OH",
"short_code": "OH",
"subdivision_name": "Ohio",
"subdivision_category": "state"
},
{
"code": "US-OK",
"short_code": "OK",
"subdivision_name": "Oklahoma",
"subdivision_category": "state"
},
{
"code": "US-OR",
"short_code": "OR",
"subdivision_name": "Oregon",
"subdivision_category": "state"
},
{
"code": "US-PA",
"short_code": "PA",
"subdivision_name": "Pennsylvania",
"subdivision_category": "state"
},
{
"code": "US-RI",
"short_code": "RI",
"subdivision_name": "Rhode Island",
"subdivision_category": "state"
},
{
"code": "US-SC",
"short_code": "SC",
"subdivision_name": "South Carolina",
"subdivision_category": "state"
},
{
"code": "US-SD",
"short_code": "SD",
"subdivision_name": "South Dakota",
"subdivision_category": "state"
},
{
"code": "US-TN",
"short_code": "TN",
"subdivision_name": "Tennessee",
"subdivision_category": "state"
},
{
"code": "US-TX",
"short_code": "TX",
"subdivision_name": "Texas",
"subdivision_category": "state"
},
{
"code": "US-UT",
"short_code": "UT",
"subdivision_name": "Utah",
"subdivision_category": "state"
},
{
"code": "US-VT",
"short_code": "VT",
"subdivision_name": "Vermont",
"subdivision_category": "state"
},
{
"code": "US-VA",
"short_code": "VA",
"subdivision_name": "Virginia",
"subdivision_category": "state"
},
{
"code": "US-WA",
"short_code": "WA",
"subdivision_name": "Washington",
"subdivision_category": "state"
},
{
"code": "US-WV",
"short_code": "WV",
"subdivision_name": "West Virginia",
"subdivision_category": "state"
},
{
"code": "US-WI",
"short_code": "WI",
"subdivision_name": "Wisconsin",
"subdivision_category": "state"
},
{
"code": "US-WY",
"short_code": "WY",
"subdivision_name": "Wyoming",
"subdivision_category": "state"
},
{
"code": "US-DC",
"short_code": "DC",
"subdivision_name": "District of Columbia",
"subdivision_category": "district"
},
{
"code": "US-AS",
"short_code": "AS",
"subdivision_name": "American Samoa",
"subdivision_category": "outlying area"
},
{
"code": "US-GU",
"short_code": "GU",
"subdivision_name": "Guam",
"subdivision_category": "outlying area"
},
{
"code": "US-MP",
"short_code": "MP",
"subdivision_name": "Northern Mariana Islands",
"subdivision_category": "outlying area"
},
{
"code": "US-PR",
"short_code": "PR",
"subdivision_name": "Puerto Rico",
"subdivision_category": "outlying area"
},
{
"code": "US-UM",
"short_code": "UM",
"subdivision_name": "United States Minor Outlying Islands",
"subdivision_category": "outlying area"
},
{
"code": "US-VI",
"short_code": "VI",
"subdivision_name": "Virgin Islands, U.S.",
"subdivision_category": "outlying area"
}
]
}
25 changes: 13 additions & 12 deletions chronam_issue_counts/README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
<h1>Overview</h1>
<p>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.</p>
<p>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.</p>
<p>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.</p>
<p>The primary script is named "state_issues.py" 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.</p>
<p>Please visit https://chroniclingamerica.loc.gov/about/api/ for background information about the various views of data available from Chronicling America.</p>

<h1>Output</h1>
<b>state_issues_year_2019_DC.py or other files with state/territory abbreviations</b>
<p>The 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.</p>
<b>state_issues_year_2019_NOSTATE</b>
<p>Use 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.</p>
<b>state_issues.py</b>
<p>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.</p>

<h1>Dependencies</h1>
<p>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.</p>
<p>To run this script, you'll need to have Python 3 installed and the requests library downloaded. You will also need access to a command line interface such as Terminal on OS X, Anaconda on Windows, or other.</p>

<h1>Instructions</h1>
<p>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.</p>
<p>Save the "state_issues.py" and "ISO_3166-2:US.txt" files to a folder where you want the results file saved. Using the command line interface, navigate to the folder.</p>

<p>Run the script by typing: "python state_issues_year_2019_[state_abbreviation]"</p>
<p>Ex: python state_issues_year_2019_DC.py</p>
<p>Run the script by typing: <code>python state_issues.py [two letter state code or full state name]</code></p>
<p>Ex: <code>python state_issues.py TN</code></p>
<p>Ex: <code>python state_issues.py Tennessee</code></p>
<p>State names with multiple words should be wrapped in quotes.</p>
<p>Ex: <code>python state_issues.py "District of Columbia"</code></p>
<p>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.</p>
<p>Optionally, input validation can be skipped by adding the force flag.</p>
<p>Ex: <code>python state_issues.py Piedmont --force</code></p>

<h1>Customizations</h1>
<p>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.</p>

<h1>Implementation</h1>
<p>We used this script to pull data from Chronicling America to create data visualizations available at http://www.loc.gov/ndnp/data-visualizations/.</p>
Expand Down
1 change: 1 addition & 0 deletions chronam_issue_counts/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests
Loading