Skip to content

Instantly share code, notes, and snippets.

@baddeiv
baddeiv / parseml.py
Created August 10, 2021 09:17 — forked from urschrei/parseml.py
Extract attachments from EML files in the current dir, and write them to the output subdir
#!/usr/bin/env python
"""
2020 update:
- More iterators, fewer lists
- Python 3 compatible
- Processes files in parallel
(one thread per CPU, but that's not really how it works)
"""
@baddeiv
baddeiv / copy-to-psql.py
Created August 12, 2021 10:53 — forked from katylava/copy-to-psql.py
script to load csv file into new postgres table
#!/usr/bin/env python
import re
from subprocess import call
def load_csv_psql(db, infile, table, tmpdir='/tmp'):
tmpfile = '%s/%s' % (tmpdir, infile)
call(['cp', infile, tmpfile])
columns = map(variablize, file(infile).readline().split(','))