|
Cookbook /
CSVIncludeSummary: Include a CSV file as a table in your wiki page
Version:
Prerequisites:
Status:
Maintainer: LarryBaltz
Categories: Includes, Administration
GoalLarge, complex tables are a pain to maintain in mark-up (wiki or HMTL). It would be nice to have a straightforward way to maintain tables in a spreadsheet tool and then include them directly into the wiki. SolutionCSVInclude.phpΔ (internal RCS version 1.4)
Put Add the following line to local/config.php: include_once("cookbook/CSVInclude.php");
Use mark-up like DiscussionWiki mark-up is great for simple tables but they get hairy to create and maintain where there are a lot of columns or the cell contents are long. In these cases, it really is more natural to maintain the table contents in a spreadsheet tool and simply include the table into the wiki. The CSVInclude cookbook file allows you to upload a CSV file you've exported from a spreadsheet and have it appear as part of your wiki page. Cells can contain wiki mark-up just as if the text were between the "||" (double pipe) mark-up in a simple wiki table. This also means that you can't use block mark-up in your tables (i.e. no bullets, headers or indentation). Why CSV vs. Excel or SYLK or something like that? Well CSV is pretty much the lowest common denominator for spreadsheet file formats and because there are CSV parsing routines already in PHP. Also, dealing with Excel or some more "advanced" file format would involve resolving formulas and multiple sheets within the same file, which I really don't want to deal with. It's also reasonable to edit CSV by hand or post process CSV by hand in a text editor, which is pretty much impossible in other formats. The CSVInclude currently uses Table mark-up, if for no other reason, because advanced table mark-up is currently not available for PmWiki2. It's also a nice choice because of mark-up goodies like headers and alignment which would be a lot more work in the advanced table mark-up. In general, it seems that the Table mark-up matches with CSV pretty well. I haven't done extensive testing with all the possible CSV output that may be possible. In particular I've only really tested this with CSV output from OpenOffice, so feedback on how it works (and doesn't work) with other spreadsheets would be much appreciated. Usage NotesGetting The CSV File In-line
Wiki Page Mark-upThe full mark-up is as follows:
: Maybe some example would help:
Mark-up within CSV tablesThe contents of the CSV file are inlined into the wiki text of the page, so you can include wiki mark-up in your CSV cells. Anything that will work between double bar table mark-up in the wiki will work within the cells of the CSV table. A couple of special mark-ups are available in the CSV table:
See Also
Contributor |