Search and replace
-
Is there a way to perform a search and replace for a particular term across the tables? I want to convert some of the text into links and it is not practical to edit the tables one by one.
-
Hi,
thanks for your question, and sorry for the trouble.
No, sorry, there’s no such option directly in TablePress. My suggestion here is to use a plugin that can search/replace directly in the database. There, all tables are stored as the Custom Post Type “tablepress_table” in the “wp_posts” table. Thus, you should limit the search/replace to those mySQL table rows.
Then, as you would be working directly on the database, don’t forget to create a backup first!Regards,
TobiasHi Tobias,
Thanks for the quick reply. You just confirmed my fears. I guess I’ll just have to bite the bullet and give it a go.
Hi,
no worries, it’s not that hard 🙂 Just be sure to have a backup so that you have a way to restore the data, if something goes wrong.
In fact, you could also try a different way: You could export all your tables to CSV files and then use a “Search/Replace” over all of those files, which most text editor programs make possible. Then, just re-import the tables into TablePress.
Regards,
TobiasHi Tobias,
I don’t think exporting to CSV works because some table contents content HTML. That’s why I have been importing using HTML instead of CSV. Unless there is a way around this that I’m not aware of.
Hi,
don’t worry, exporting to CSV here will work fine, as the HTML code will simply be treated as text and it will be kept.
Regards,
TobiasHi Tobias,
Would I be able to re-import via CSV with the HTML?
Hi,
yes, of course. After the re-import, the HTML will be treated as HTML again.
Regards,
TobiasHi Tobias,
Thank you so much! It works now! I previously tried to import CSV with HTML but it threw an error, hence the confusion regarding how to import/export CSV with HTML. Now I know I need to had quotation marks to escape the HTML.
Yes, this is definitely going to be very helpful going forward. It is a much safer way to do this without having to muck around with the database. And I can do a simple search and replace across all the CSV files.
Hi,
no problem, you are very welcome! 🙂 Good to hear that this helped!
Yes, quotation marks are the only problematic thing here, as they are used for wrapping the cell content. Therefore, all quotation marks in the HTML needs to be escaped with a second quotation mark. During the export, this happens automatically.
Best wishes,
TobiasP.S.: In case you haven’t, please rate TablePress here in the plugin directory. Thanks!
Hi Tobias,
Yes, I hope this will be useful to others who are trying to do the same thing as me. Being able to use CSV makes it a lot easier to create the tables. And preserving HTML makes it easier to style and present the data.
It might be useful to add the bit about CSV importing to the FAQ or documentation. I looked around for help on that but gave up when nothing turned up. Or perhaps I missed it completely.
Another point to add it that quotation marks need to be escaped too.
So if people who want to output:
<a href=“http://url/“>
will have to use
"<a href=""http://url/"">”I hope this helps others who come across this post.
Thanks once again, Tobias. I will definitely rate the plugin because this is the best table plugin for WordPress. =)
Hi,
yes, that’s what I meant above 🙂 Quotation marks have to be escaped with a second one, as that seems to be the most common handling of the escaping issue in CSV (see e.g. http://en.wikipedia.org/wiki/Comma-separated_values )
And thanks for the rating, I really appreciate it!
Best wishes,
TobiasWhat plugin do you recommend that does a search and replace directly in the database? I need to replace about 500 fields in Tablepress. I usually use Velvet Blues to update URLs on a site, but that doesn’t seem to work for Tablepress.
Thank you,
LauraHi Laura,
I’m not really familiar with such plugins, unfortunately, as I usually just do it directly with a SQL in the database (using a tool like phpMyAdmin on the server). Thus, I can’t really recommend one, sorry 🙁
Regards,
Tobias
The topic ‘Search and replace’ is closed to new replies.