Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2009-07-06 17:06:49
- cruisejente
- New Member
- Registered: 2009-07-06
- Posts: 1
Table data in textpattern
We are a sports league who would like to upload our schedule on a web site and are looking at using textpattern. Is it posssible (and easy!) to upload a .csv file and have textpattern format it for display on our web site? It only needs to be displayed in a simple layout.
Many thanks for your help.
Offline
Re: Table data in textpattern
It is pretty simple to convert csv to a Textile -formatted table, then paste that into a Txp article for display.
It would also be pretty simple for a plugin author to make a plugin that would read the csv file from a directory on the web server and output the table in a Txp article or directly onto a Txp page template.
Code is topiary
Offline
Re: Table data in textpattern
- Replace all commas with a tilde (~) or some other unlikely character.
- Export or Save as a CSV file.
- Open the CSV file in TextWrangler or other suitable Text Editor. The former has a particular advantage in this task.
- Replace all commas (,) with a pipe (|).
- Prepend and Append a pipe (|) to each row, Textwrangler has this as an automatic option under Text/Prefix Suffix Lines.
- Replace all || with |-| twice to get content into empty table cells to stop them collapsing and indicate that there is no data for that cell.
- Replace all tilde (~) with commas (,) to restore them in the original text.
- Process the header row to add a _. plus a space after each pipe (|) and delete it after the last one if necessary.
- Copy and paste the Textile source into the article in the TXP backend et vôila!
I know that it’s possible to use other delimiters than a comma to obviate the need for the tilde comma swaps but it isn’t an option with the Mac version of Excel (as far as I know).
Offline
Re: Table data in textpattern
Joe, may I suggest using tabs as the delimiter for your CSV files? Then you wouldn’t have to do the comma swap. Unless you expect tabs within your data…
Code is topiary
Offline
Re: Table data in textpattern
Also, check these two threads: yab_csv2table:
# Name: yab_csv2table v0.1
# Type: Client side plugin
# Generating HTML table from simple csv files
and aks_table:
Insert a table in TxP article is very simple!
Select in Excel, IE, Mozilla, FireFox, Opera any spreadsheet,
Ctrl + C (copy) and Ctrl + V (paste) in TxP Edit area.
Add aks_table tags – that’s all.
TXP Builders – finely-crafted code, design and txp
Online
Re: Table data in textpattern
Jeff,
Thanks for the kind thought. I like the visual control that having a comma provides as opposed to a blank tab immersed in a blank sea. Also, to be candid, I haven’t worked out how to search for a tab in Textwrangler. It’s quicker for me to do the swap and get on with it.
Joe
Offline
Re: Table data in textpattern
I understand about the visual cue. At any rate, to find a tab character with TW use \t
(backslash-t). Or you can even copy and paste a tab character into the “Search for” field!
Also, “Show invisibles” lets you see the tab characters. You can find this in the little pop-down text menu (not the main Text menu in the menu bar, but the little “T” with a lightswitch menu in the Toolbar).
Last edited by jsoo (2009-07-06 19:35:18)
Code is topiary
Offline
Re: Table data in textpattern
Very many thanks!
Offline
Re: Table data in textpattern
Offline
Pages: 1