Importing mbox file to paperless-ngx? reddit / selfhosted ---------------------------------------------------------------------- friend_in_rome · 2023-11-29 15:01 I have an mbox file of a bunch of old gmail, created via gmail takeout. I'd like to import it into paperless-ngx. I found a python script to extract attachments from an mbox file, but I want the whole thing -- email and attachments -- imported. I tried dropping the mbox file directly in the `consume` directory but got `[WARNING] [paperless.management.consumer] Not consuming file /usr/src/paperless/consume/test.mbox: Unknown file extension.` so clearly that's not the right way. It looks like maybe I coud hack something up with an imap server, tell it to serve that mbox file, and point paperless at the server. That's ugly. Is there some way to import an mbox file directly into paperless-ngx without going down the imap server hack route? Or failing that, some container setup out there which does the imap server thing right out of the box so I don't have to figure all that out? thanks! ---------------------------------------------------------------------- bigbyfindrake · 2023-11-29 16:04 Run the mbox file through formail with "-s", something like this: `cat file.mbox | formail -s /bin/sh -c 'cat > $FILENO.txt'` That will split up your mbox file into one file per message ---------------------------------------------------------------------- friend_in_rome · 2023-11-29 19:16 That didn't quite work, I ended up with one file called `000.txt` that had the whole mbox in it, so something is off on the pattern recognition. But your idea makes sense and it seems easy enough to hack up a script to just look for `^From ` and dump that to individual files, so I'll give it a shot. Thanks! ---------------------------------------------------------------------- bigbyfindrake · 2023-11-29 20:28 Excellent! Nicely done. Do/can you program in languages other than python? I ask because I have been looking for a "multi-lingual" person who can tell me about the benefits of python as compared to other languages, and I haven't really found anyone so far who was able to compare and contrast; all of the pythites I've found have pretty much *only* used python, so they couldn't tell me why you should use it as opposed to another language. I know several other langauges, and I administer fine enough with them, but python has been all the rage for some few years now, and I haven't been able to muster the motivation to learn it, probably mostly/mainly because I don't know how it would benefit me. Would you be willing to sell me on, to advocate for Python from your perspective? Cheers, me ---------------------------------------------------------------------- friend_in_rome · 2023-11-30 00:32 I started my career programming in perl, did python a whole lot for a long time, and have been dabbling in go as a side project. I am not a professional programmer but am in a programming-adjacent field so I use it a lot. There are lots and lots of opinions out there about exactly what you're asking. Mine is just one of them. I think Python is a good first language because it's easy to make simple stuff quickly. Go is a good second language because it's got enough C-like stuff in there that it's exposure to a whole different way of thinking about programming. I know very little about Erlang derivatives and Lisp stuff and other fancy CS things like that. [This](https://preslav.me/2023/11/27/python-is-easy-golang-is-simple- simple-is-not-easy/) is a pretty good article. ---------------------------------------------------------------------- bigbyfindrake · 2023-11-30 13:56 How did your import into paperless go? Did it work as desired? ---------------------------------------------------------------------- friend_in_rome · 2023-12-03 15:58 It worked insofar as it brought the text into paperless. But it pulled in the entire email as a text file, which really isn't much of a surprise but makes it pretty hard to search because I can't search by mail headers; it's all just text to paperless. I'm going to delete all the email files and maybe get around to the imap server thing someday, perhaps that'll import mail better. I sure wish there was an easy way to import an mbox file as email, rather than this hacky split-and-import-as-text thing.