Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-04-12 03:58:07

code365
Member
From: California
Registered: 2009-08-16
Posts: 69

Import into database

Does anyone know of it’s possible to import csv into txp database without copying and pasting?

Thank you

Offline

#2 2020-04-12 08:31:40

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 9,282
Website

Re: Import into database

You can import XML fairly easily if you can wrangle your content into that format, but short of doing it in the database directly, CSV will probably require a plugin. I think there was jmd_csv but it’s probably out of date now.

Does anybody know of any routes that are still open?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2020-04-12 09:16:26

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,807
Website

Re: Import into database

You can import csv directly into the database via phpMyAdmin but it needs doing with great care. Essentially you need to recreate the format of the textpattern table in the Textpattern database as a table in excel/numbers etc. taking care to use unused article ID numbers (to avoid overwriting existing data). Export that to a csv file for importing into the database (making sure you have a backup if things don’t work as planned). You need to take care with your csv export to ensure line endings and quotes in your Body field don’t cause wrong wrapping. And after importing, you need to bulk-textile all your entries with a plugin like sed_textile_upgrade. That’s the final part.

If this is a one-off exercise you only need to do once in bulk at the beginning of the project, it can save time over individual article entry, especially if you have a large number of articles to deal with. If you need to link these up to images, it’s worth preparing and working it all out carefully in advance. We could help you with some guidance or do this for you as a service.

If you need to do it regularly, you may want to investigate converting your csv entries into an xml for smd_xml as Bloke wrote, or into file-like articles (like the welcome article during Textpattern’s setup; also in XML) for importing in conjunction with a (yet to be written, i.e. commissioned) plugin.


TXP Builders – finely-crafted code, design and txp

Offline

#4 2020-04-15 13:22:06

code365
Member
From: California
Registered: 2009-08-16
Posts: 69

Re: Import into database

Thank you guys so much. I will either try XML.

Offline

Board footer

Powered by FluxBB