A Python 3 script to convert a CSV file to a folder of Kirby CMS content files.
If you're moving from A N Other CMS to Kirby you've probably got to transfer the pages and blog posts from the older system. Assuming these are stored in an SQL file you can export them as CSV and run that file (after a bit of tidying up) through this script to generate a folder full of Kirby .txt content files.
- Run the Python script.
- Select the CSV file you wish to convert.
- Input the .yml file name you wish to use. Each row of the csv will be turned into a name.txt file in its own folder.
- Select where you want to save the created files and folders.
- The first row of the CSV file is taken to be a header row for the columns. One of these headers must be 'title' (lower case) but the rest can be anything you like.
- The script will create YAML files using the cells in the header row to create the categories (ie the CSV header maintext would become maintext: in the YAML file.
Several Python modules are required for the Comma to Colon:
- CSV — For reading and writing CSV files
- OS — For accessing the file system
- Tkinter — For file dialog boxes (you could rewrite the script to remove this one if you don't want to use Tkinter)
Try Kirby for free: https://getkirby.com/ then buy a licence when you realise just how great a CMS it is.
If you feel like buying me a cup of tea for writing the script, tip me here: https://www.paypal.me/mylesw42