<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Irregular Expressions</title>
<subtitle>Posts tagged “Python”</subtitle>
<id>https://chaseleinart.com/tags/python/feed.xml</id>
<link href="https://chaseleinart.com/tags/python/feed.xml" rel="self" />
<link href="https://chaseleinart.com/" />
<updated>2025-07-31T00:00:00.000Z</updated>
<entry>
<title>Opportunities for Digitization in the Humanities - The Etruscan Texts Project</title>
<id>https://chaseleinart.com/posts/opportunities-for-digitization-in-the-humanities-the-etruscan-texts-project/</id>
<link href="https://chaseleinart.com/posts/opportunities-for-digitization-in-the-humanities-the-etruscan-texts-project/" rel="alternate" />
<published>2025-07-31T00:00:00.000Z</published>
<updated>2025-07-31T00:00:00.000Z</updated>
<author><name>Chase Leinart</name><email>chaseleinart@proton.me</email></author>
<category term="Etruscan" />
<category term="Digital Humanities" />
<category term="Python" />
<category term="Linguistics" />
<content type="html">&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note - This post was originally published on my Etruscan Studies Blog at the following &lt;a href=&quot;https://etruscanstudies.hcommons.org/2024/02/10/etruscan-texts-project-opportunities/&quot;&gt;link&lt;/a&gt; on 2024-02-10&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In my recent foray into researching the Etruscan language, I came across the the Etruscan Texts Project (ETP), which served as a searchable online repository of Etruscan inscriptions. I found references and links to the website on active UMass Amherst webpages and elsewhere, but the links themselves were dead. With a bit of sleuthing on the Wayback Machine, the most recently indexed working copy of the &lt;a href=&quot;http://web.archive.org/web/20091126015235/http://etp.classics.umass.edu/cgi-bin/query.pl&quot;&gt;ETP site&lt;/a&gt; I could find was dated to late 2009. Copies indexed from 2011 onward return 404 errors, and reveal that the server hosting the ETP was migrated from Ubuntu to Unix. The linked version of the ETP has entries labelled up to #430, though the jump from ETP 405 to ETP 407 omitted 406, for a total of 429 records.&lt;/p&gt;
&lt;p&gt;Details available from the &lt;a href=&quot;https://epidoc.stoa.org/https://www.umass.edu/etruscannews/articles&quot;&gt;following PDF&lt;/a&gt;, sourced from Etruscan News 5 (2006), note that the ETP was in the process of migrating its existing catalog to &lt;a href=&quot;https://epidoc.stoa.org/&quot;&gt;EpiDoc&lt;/a&gt;, an XML format for encoding scholarly and educational editions of ancient documents. It’s not clear to me from the outside what the current state of the project is, but I took it upon myself to experiment with the data available. After downloading a copy of the archived website, I wrote &lt;a href=&quot;https://github.com/chaseleinart/etp-data/blob/main/etp-scraper.py&quot;&gt;this&lt;/a&gt; little Python script using &lt;a href=&quot;https://beautiful-soup-4.readthedocs.io/en/latest/&quot;&gt;Beautiful Soup&lt;/a&gt;, a package for pulling data out of XML and HTML files.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes gruvbox-light-soft gruvbox-dark-soft&quot; style=&quot;background-color:#f2e5bc;--shiki-dark-bg:#32302f;color:#3c3836;--shiki-dark:#ebdbb2; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;from bs4 import BeautifulSoup&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;inputFile = open(&quot;/path/to/file.html&quot;, &quot;r&quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;outputFile = open(&apos;/path/to/output.csv&apos;, &apos;w&apos;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;content = inputFile.read()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;soup = BeautifulSoup(content, &apos;html.parser&apos;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;# array to hold list of ETP entries&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;outputFileEntries = []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;for entry in soup.find_all(&quot;div&quot;, class_=&quot;document&quot;):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	# string to hold a tentative CSV file single-line for an entry&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	outputFileLine = &apos;&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	for tag in entry:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		if tag.name is not None:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;			formattedTagText = &apos;\t&apos;.join([line.strip() for line in tag.text.split(&apos;\n&apos;)])&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;			outputFileLine = outputFileLine + &quot;\&quot;&quot; + formattedTagText + &quot;\&quot;&quot; +  &apos;, &apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	outputFileEntries.append(outputFileLine)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;for line in outputFileEntries:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	outputFile.write(line + &quot;\n&quot;) &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;inputFile.close()&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;outputFile.close()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This code looks for a div tag specific to the archived ETP page, writing each of its attributes as quoted and comma-separated values, forming lines of a CSV file (available &lt;a href=&quot;https://github.com/chaseleinart/etp-data/blob/main/ETRUSCAN_TEXTS.csv&quot;&gt;here&lt;/a&gt;). Using LibreOffice Calc, I fixed some of the formatting present in the data by default, and used DB Browser for SQLite to convert the CSV file into a SQLite database file (available &lt;a href=&quot;https://github.com/chaseleinart/etp-data/blob/main/ETRUSCAN_TEXTS.csv&quot;&gt;here&lt;/a&gt;). SQLite is a great little database engine that allows embedding a DB in an application as a single file. It may not be a perfect fit for all use-cases, but for surfacing a small amount of catalog data, it’s a nice quick hit for little projects.&lt;/p&gt;
&lt;p&gt;While considering options, I learned of a tool called &lt;a href=&quot;https://datasette.io/&quot;&gt;Datasette&lt;/a&gt;, which frames itself as “a tool for exploring and publishing data…aimed at data journalists, museum curators, archivists, local governments, scientists, researchers and anyone else who has data that they wish to share with the world.” I was able to find the easiest way to interact with Datasette, as a Glitch webapp. I forked the app, inserting my own CSV file for the ETP catalog data, and have it running &lt;a href=&quot;https://glitch.com/edit/#!/keen-melodic-cornflower&quot;&gt;here&lt;/a&gt; (&lt;strong&gt;Note: as of July 8, 2025, Glitch has decommed all its hosting. I&apos;ll need to move it to my own hosting at some point&lt;/strong&gt;). The README provides instructions on getting it running. The screenshot below demonstrates running a simple query of the ETP data inside the terminal provided by the app. For those unfamiliar with some of the tooling involved with generating databases or surfacing them via APIs, this is a great toolkit!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://chaseleinart.com/images/glitch-app-pic.png&quot; alt=&quot;Glitch App&quot;&gt;&lt;/p&gt;
&lt;h1 id=&quot;next-steps&quot;&gt;Next Steps&lt;/h1&gt;
&lt;p&gt;I’ve scraped a (possibly very) outdated version of the ETP catalog from the Wayback Machine and migrated it to a database. I’d like to learn more about the need or desire for data like this to remain easily and publicly accessible. It would be straightforward to create a new website that hosts the database, but questions remain about the format of the data, its accuracy, and the best way to enter new inscriptions. Although it remains popular in certain domains, in many cases, XML has been largely obsoleted by JSON, which some may consider an easier format to work with. There may be alternatives to EpiDoc that are more accessible to current tooling. Ultimately, I would love to be involved in any efforts related to digitally cataloging Etruscan inscriptions (or similar needs for other historical languages). If you work in the field and would like to partner with me as an independent researcher or assistant on a part-time basis, please consider getting in touch with me either by comment here or via my email (chaseleinart at proton dot me).&lt;/p&gt;</content>
</entry>
<entry>
<title>Publishing Data Online with Datasette - ETP</title>
<id>https://chaseleinart.com/posts/publishing-data-online-with-datasette-etp/</id>
<link href="https://chaseleinart.com/posts/publishing-data-online-with-datasette-etp/" rel="alternate" />
<published>2025-07-31T00:00:00.000Z</published>
<updated>2025-07-31T00:00:00.000Z</updated>
<author><name>Chase Leinart</name><email>chaseleinart@proton.me</email></author>
<category term="Etruscan" />
<category term="Digital Humanities" />
<category term="Python" />
<category term="Linguistics" />
<content type="html">&lt;p&gt;&lt;em&gt;&lt;strong&gt;Note - This post was originally published on my Etruscan Studies Blog at the following &lt;a href=&quot;https://etruscanstudies.hcommons.org/2024/02/13/publishing-data-online-with-datasette-etp/&quot;&gt;link&lt;/a&gt; on 2024-02-13&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;In my previous &lt;a href=&quot;https://chaseleinart.com/posts/opportunities-for-digitization-in-the-humanities-the-etruscan-texts-project/&quot;&gt;post&lt;/a&gt;, I mentioned a tool called Datasette, a neat open-source tool for exploring and publishing data. I explained how I scraped an archived copy of the Etruscan Texts Project (ETP) and ultimately populated it into a SQLite DB using a Python script I wrote. Following up on that, I wanted to explore the easiest ways to surface the data online in a browsable way. Reading further about Datasette, I realized that Datasette itself fits my use-case perfectly.&lt;/p&gt;
&lt;p&gt;To get started, all you need to do is create a Heroku account and an application. Configure your application to use Heroku CLI and install it on your computer. To use Datasette, you’ll need to install Python 3 on your personal computer and install the datasette package. On my Debian box, I installed it using pipx, to manage it in an isolated environment.&lt;/p&gt;
&lt;p&gt;From there, I simply used the following command to use my SQLite db file as the source for Datasette to publish, having already logged into Heroku using the CLI.&lt;/p&gt;
&lt;p&gt;datasette publish heroku etruscan-texts.db --name &quot;etruscan-texts&quot;&lt;/p&gt;
&lt;p&gt;Running this command will serve up a website with the name you provide, which will be displayed in the console. You can click on the following link to view my &lt;a href=&quot;https://etruscan-texts-b8825ecac007.herokuapp.com/etruscan-texts/ETRUSCAN_TEXTS&quot;&gt;published copy of the ETP&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://chaseleinart.com/images/etruscan-texts-db-app.png&quot; alt=&quot;/Etruscan Texts DB App&quot;&gt;&lt;/p&gt;
&lt;p&gt;This is such a great way to get a data set online without needing to provide your own web server, view engine, tables + filtering in code. Now that this copy of the ETP is available online, anyone is welcome to use it or recommend fixes and additions. I’m aware that ETP 406 was omitted, causing the assigned numbers after that to no longer be a correct sequence. I’ll provide a fix for that in the near future and document what follows.&lt;/p&gt;</content>
</entry>
</feed>
