This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For background information, DOCX files are ZIP archives containing XML files. | |
# I had a recent project that needed comments extracted from several MS Word documents. | |
# This would have been painful to do manually - command line to the rescue! | |
find . -name "*.docx" -exec sh -c 'unzip -p $1 word/comments.xml | xmllint -xpath "//text()" -' sh {} \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import boto3 | |
from sys import argv | |
""" | |
Example of undeleting in S3 with specified key prefix | |
""" | |
def restore_bag(bagname): | |
""" undelete derivative bag """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from jinja2 import Environment | |
mytemp = """ | |
my box number is {{ "%(box)04d"|format(box=mybox) }} | |
""" | |
print Environment().from_string(mytemp).render(mybox=456) | |
# my box number is 0456 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
purchases = [12, 43, 13, 465, 1, 13] | |
n = 2 | |
d = 3 | |
class Prizes(object): | |
def __init__(self, purchases1, n1, d1): | |
self.pu = purchases1 | |
self.n = n1 | |
self.d = d1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
# Iterate over author pages | |
for page in range(1, 2): #TODO: update to number of pages + 1 (i.e. 15 pages would be 16) | |
data = {"gruppo": "autori", | |
"iniziale": "all", | |
"pag": page} | |
response = requests.post("http://digiliblt.lett.unipmn.it/testi.php", data=data) | |
soup = BeautifulSoup(response.text, "lxml") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
df = pd.DataFrame.from_csv(r"append_test.txt", sep='\t') | |
frames = [] | |
for meeting in range(len(df.T)): # iterate over recorded attendances | |
attendees = df[df.T.iloc[meeting] == 1].index # get attendees for specific meeting | |
frames.append(pd.DataFrame(index=attendees, columns=attendees).fillna(1)) # create frame from attendees | |
# sum up jointly attended meetings |