Zimmwriter Txt To CSV Python Automation: No More Copy and Paste!

Steve Goldberg
April 4, 2023
5 minutes read

Are you drowning in a sea of Zimmwriter-generated text files, struggling to stay afloat in the treacherous waters of manual copy-pasting?

Fear not, for the miraculous life raft of a Python script (crafted by none other than the genius chatgpt) has come to rescue you from the abyss!

This awe-inspiring script will not only pluck your precious articles from the depths of disarray and place them neatly into a single CSV file, but it will also separate the titles, meta descriptions, and content into their respective columns with a finesse that would make even Houdini envious.

Behold the majestic power of this Python script as it not only saves you precious time and effort, but also has the potential to regrow your hair, breathe new life into your marriage, and catapult you to the dizzying heights of millionaire status!

So, brace yourself for the mind-blowing transformation that awaits you and your WordPress site!

P.S. I did not write any of this intro.


As of April 7th, 2023 you no longer need to follow the tutorial below since I’ve made a standalone Mac app that let’s you choose your txt files and automatically converts them!

You can download the app here. You may need to give the app permission to run since it is a simple python app and not from a verified developer.

If you are on Windows, hang tight. I’ll try to get a working Windows version out soon. In the meantime, you can follow the tutorial below.

Step 1: Install Python

  • Download and install Python from the official website.
  • Make sure to check the “Add Python to PATH” option during installation.

Step 2: Install a Text Editor

Step 3: Prepare the Python Script & CSV

  • Open the text editor and create a new file.
  • Copy and paste the provided Python script into the file.
  • Save the file with a .py extension, e.g., txt_to_csv.py
  • Create a BLANK .csv file called output.csv
  • Update the highlighted fields to your file paths
import os
import csv
import re

def process_folder(folder_path, output_file):
    header_regex = re.compile(r'@ Main model used:.*?@ Settings used:.*?\n', re.DOTALL)
    midjourney_regex = re.compile(r'@ Midjourney AI Image Prompt: (.*?)\n')
    metadescription_regex = re.compile(r'@ Meta Description: (.*?)\n')
    heading_regex = re.compile(r'(#+)\s+(.*)')

    with open(output_file, 'w', newline='') as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(['Content', 'Title', 'MetaDescription', 'Midjourney'])

        for filename in os.listdir(folder_path):
            if filename.endswith('.txt'):
                with open(os.path.join(folder_path, filename), 'r') as file:
                    text = file.read()

                    # Remove header
                    text = header_regex.sub('', text)

                    # Extract Midjourney prompt if it exists
                    midjourney_match = midjourney_regex.search(text)
                    if midjourney_match:
                        midjourney = midjourney_match.group(1).strip()
                        midjourney = ''

                    # Extract Meta Description if it exists
                    metadescription_match = metadescription_regex.search(text)
                    if metadescription_match:
                        metadescription = metadescription_match.group(1).strip()
                        metadescription = ''

                    # Extract title and content
                    title_match = re.search(r'# (.+)', text)
                    if title_match:
                        title = title_match.group(1).strip()
                        text = text.replace(title_match.group(0), '', 1)
                        title = ''

                    content = text.strip()

                    # Replace headings with appropriate tags
                    def replace_headings(match):
                        num_hashes = len(match.group(1))
                        if num_hashes == 2:
                            return f'<h2>{match.group(2)}</h2>'
                        elif num_hashes == 3:
                            return f'<h3>{match.group(2)}</h3>'
                            return match.group(0)
                    content = heading_regex.sub(replace_headings, content)

                    writer.writerow([content, title, metadescription, midjourney])

process_folder('/Users/username/folder/', '/Users/username/folder/output.csv')

File path examples for Windows and Mac

Here are two examples of file paths for the shared folder and output CSV file on macOS and Windows.


Shared folder path: /Users/JohnDoe/Desktop/Zimmwriter
Output CSV file path: /Users/JohnDoe/Desktop/Zimmwriter/output.csv


Shared folder path: C:\Users\JaneDoe\Desktop\Zimmwriter
Output CSV file path: C:\Users\JaneDoe\Desktop\Zimmwriter\output.csv

Make sure your file path is placed between the ‘ ‘ quotes.

Steve Goldberg (not ChatGpt)

Step 4: Navigate to the Script Folder

  • Locate the folder containing the .txt files and .py script on your computer.
  • Open the Terminal app on macOS or the Command Prompt on Windows.
  • On Mac, right click, go to Services, click Open New Window In Terminal

Step 5: For Windows Users

  • On windows, Click Start → All Programs → Accessories. To run the command prompt, click Command Prompt. To run the command prompt as an administrator, right-click Command Prompt and select Run as administrator from the shortcut menu.
  • Use the cd command to change the current directory to the folder containing the txt_to_csv.py script.
  • Depending on where you folder is, you may have to go down multiple directories. It’s easiest to find on the Desktop, so I suggest placing your txt files in a folder there.

Step 7: Run the Python Script

  • Type python3 txt_to_csv.py and press Enter to execute the script.

Step 8: Check the Output CSV File

  • Locate the output CSV file in the specified output directory.
  • Open the file to verify that the text files have been processed and their content is correctly placed in the CSV file.
  • You do not need to make any edits. The columns headers are setup for direct import into WordPress, even with the

Step 8: Upload Content

Now you can upload your content using Wp All Import. You can follow what I did in this video and save a template for easy future use.

You can ignore the midjourney prompt on import unless you want to save it in WordPress for some weird reason.


I’ll update this section with some questions or issues. I plan to keep this script running until this feature is natively added to Zimmwriter.


Since making the video I made changes:

  • Add column headers to the csv so no editing is required prior to uploading to WordPress
  • Convert the h2 and h3 from markdown to html automatically (no more editing!)
  • Updated script so if there is no Midjourney or metadescription prompt it doesn’t throw an error
  • Added a UI to eliminate having to update file paths and run terminal commands.

Future Updates

If you enjoyed this video and found it helpful, be sure to subscribe to my upcoming newsletter for more AI, no code, and automation news, articles and tutorials.

I promise I won’t spam you. I’ll always ask about your interests and goals before I send you cool stuff, and you can opt out anytime!

Table of Contents

Get fresh insights and news weekly

Subscription Form

You might also like