Not logged in. · Lost password · Register
Forum: General Help and Support Plugins Plugin Wishlist RSS
Export DW tables as csv files.
action plugin to add "save as csv" button next to DW Tables...
Avatar
jjoelc #1
Member since Jan 2012 · 13 posts · Location: Amarillo TX
Group memberships: Members
Show profile · Link to this post
Subject: Export DW tables as csv files.
Given all of the utilities out there to convert .csv files to DW tables (or use them directly in DW, like the CSV plugin  http://www.dokuwiki.org/plugin:csv) this should be a relatively simple plugin, but my minimal PHP skils were last used almost 12 years ago, and likely are not up to the task, so I ask  for your help!

The way this works (in my mind at least) is the user simply surrounds a table in the wiki with a tag (<tocsv></tocsv> perhaps?) Any table inside this tag would have a button added next to it (small button similar to the "edit" button in each subsection) to convert the table to a csv file and send it to the user through the browser's regular "save file" function...

Looking at the CSV plugin's syntax.php file, it seems it would be reasonably easy to just reverse the order of processing in that plugin (taking the DW markup as source, and find/replace needed characters to spit out .csv) using php to serve out the file for the user to download is also relatively simple. That just leaves creating the button to be embedded next to the table to fire the process off.

Another possibility would be to use something like Jquery table to csv http://www.kunalbabre.com/projects/table2CSV.php to grab the HTML formatted table after DW has rendered the page, though to me this does not feel as "right" as using DWs existing infrastructure to do some of the work...

I'm willing to help in this as much as possible, though as I said my PHP skills are rather limited and probably out of date ;-)

[edit]
Some clarification on my reasoning for this...
To pick one example, we have a contact list set up as a table in our wiki. there is some overall management of course, but generally, the individual users keep this table up to date (when they move desks or get a new cell phone for example). Most of our users are not terribly computer literate. So I use FCKGLite as a WYSIWYG editor. This makes it much simpler for the users to make changes to tables, especially. With the turnover rate in our business, this table changes quite frequently. Using the CSV plug-in makes editing the table inside of the wiki either impossible (if using a linked file) or impractical to less savvy users (if using inline data) so I really need to keep the ability to edit the table in FCKGLite. However, it is incredibly useful to be able to grab that information as a csv file (on the fly, so you get the most recent version) to be imported into... well.. just about any other program... Thus, the quest to just have a button to send the user a csv file of the info in a table.
Hope that helps to clarify things more than it confuses them!
This post was edited on 2012-06-27, 18:29 by jjoelc.
Avatar
turnermm (Moderator) #2
Member since Oct 2009 · 4492 posts · Location: Canada
Group memberships: Global Moderators, Members, Super Mods
Show profile · Link to this post
If you are really very much in need of this, you can try getting individual help:  http://www.dokuwiki.org/faq:support
Myron Turner
github: https://github.com/turnermm
plugins, templates: http://www.mturner.org/devel
Avatar
tom_c #3
Member since Jan 2011 · 33 posts · Location: Hackettstown, NJ, US
Group memberships: Members
Show profile · Link to this post
I had been working on something similar so I took some of that code and created the table2csv plugin - http://www.dokuwiki.org/plugin:table2csv. This plugin was based on a table that was created using pagemod and bureaucracy plugins. It used the table html code generated from those of <table class="inline"> in order to identify the table.  That severely limits it's usability.  I will look at making that better. In the mean time it provides a base that  maybe you can use.
This post was edited on 2012-07-05, 23:23 by tom_c.
Avatar
joemouth #4
Member since May 2009 · 311 posts · Location: Aachen-Schleckheim, Germany
Group memberships: Members
Show profile · Link to this post
@tom_c

I would like to use your plugin, but with the given example it generates an empty window: "about:blank"
(DokuWiki version: Release 2013-05-10a "Weatherwax")

Any idea what could be wrong?

Thanks, Joe
Avatar
tom_c #5
Member since Jan 2011 · 33 posts · Location: Hackettstown, NJ, US
Group memberships: Members
Show profile · Link to this post
Joe,
There was a problem with the plugin that is now fixed. If you do a plugin update it should work.  The problem was with the call to read the page with the table. The call to file_get_contents with the url was returning a false due to security issues. I changed the code to use the page ID and read it as a dokuwiki page.  It should be okay now.
Regards
Tom
Avatar
joemouth #6
Member since May 2009 · 311 posts · Location: Aachen-Schleckheim, Germany
Group memberships: Members
Show profile · Link to this post
tom_c,
Thanks for your fast support, but still the same blank page.
I updated, de-/reinstalled, restarted apache but no change.

What can I do to analyse this situation?

Thanks, Joe
Avatar
tom_c #7
Member since Jan 2011 · 33 posts · Location: Hackettstown, NJ, US
Group memberships: Members
Show profile · Link to this post
Joe,
I added some error messages to the code (much more helpful than the blank page :-) ). Download the latest and see if that gives you some direction.
Tom
Avatar
joemouth #8
Member since May 2009 · 311 posts · Location: Aachen-Schleckheim, Germany
Group memberships: Members
Show profile · Link to this post
Quote by tom_c:
I added some error messages to the code (much more helpful than the blank page :-) ). Download the latest and see if that gives you some direction.

Hi Tom, I installed the new table2csv, but still the same and the page (about:blank) is still blank :-(
Debug mode is enabled, no additional informations.

May be, we are working at the wrong place?

I tried a "......?do=export_csv"  but nothing happened. How could I invoke table2csv without the tools plugin?
Avatar
tom_c #9
Member since Jan 2011 · 33 posts · Location: Hackettstown, NJ, US
Group memberships: Members
Show profile · Link to this post
Hi Joe,
Use the example provide on the plugin page. Let me know that
1) you see the tools in either the top or bottom right page corners.
2) you see the table on the page
Then selecting the csv icon should work. I do not see a problem.  Check that
3) it created a file table.csv in your root dokuwiki install folder and that the file is not empty.

If you get to step 3 and that fails try changing the file location in the table2csv/conf/default.php file to be 'lib/table2csv/table.csv'

Regards
Tom
Avatar
asheenlevrai #10
Member since Nov 2012 · 190 posts
Group memberships: Members
Show profile · Link to this post
Hello,

I know this tread is old. Sorry for hijacking it somehow

I am looking for a tool to export DW tables as CSV files (or any other type of spreadsheets). Is there anything that is actively maintained and compatible with the last version of DW?

Thank you very much in advance for your help.

Best,
-a-
Avatar
SFITCS #11
User title: Scott Ferguson
Member since Dec 2014 · 463 posts · Location: Canberra, Australia
Group memberships: Members
Show profile · Link to this post
Have you tried the plugin this thread discusses?

I haven't as copy and paste works fine for me - but it might not suit button-loving users.

Copy the contents of the table and save to a file with the .csv extension. Open with, or Import into the application of your choice. In the import editor choose "tab separated".
If that's one step too many, you can skip the "save to file" step and paste directly into a cell (the top-left cell of the area you want to occupy with the table), then select "tab separated". That's all that's required.

See attached for an example (I've saved it with MS-DOS format line endings).
The author has attached one file to this post:
Country_ISO_codes.csv.zip 2.3 kBytes
You have no permission to open this file.
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
Imprint
This board is powered by the Unclassified NewsBoard software, 20150713-dev, © 2003-2015 by Yves Goergen
Current time: 2019-02-19, 20:25:42 (UTC +01:00)