Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#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

#2 2009-07-06 17:15:14

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

#3 2009-07-06 18:30:00

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Table data in textpattern

Though it is, as jsoo suggests, a simple task to convert a CSV file to a Textile formatted table, it can be tedious and tiresome if the table is large and/or it’s a regular requirement. I follow this procedure, starting with the Excel file source. I do it on a Mac but, apart from Textwrangler, it’s much the same procedure on a PC.
  1. Replace all commas with a tilde (~) or some other unlikely character.
  2. Export or Save as a CSV file.
  3. Open the CSV file in TextWrangler or other suitable Text Editor. The former has a particular advantage in this task.
  4. Replace all commas (,) with a pipe (|).
  5. Prepend and Append a pipe (|) to each row, Textwrangler has this as an automatic option under Text/Prefix Suffix Lines.
  6. 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.
  7. Replace all tilde (~) with commas (,) to restore them in the original text.
  8. Process the header row to add a _. plus a space after each pipe (|) and delete it after the last one if necessary.
  9. 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

#4 2009-07-06 18:46:37

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

#5 2009-07-06 18:55:55

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,731
Website

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

Offline

#6 2009-07-06 19:11:00

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

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

#7 2009-07-06 19:31:15

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

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

#8 2009-07-06 21:20:07

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: Table data in textpattern

Very many thanks!

Offline

#9 2009-07-07 03:10:14

maverick
Member
From: Southeastern Michigan, USA
Registered: 2005-01-14
Posts: 976
Website

Re: Table data in textpattern

Slightly tangent –

Perhaps this plugin can be adapted to help admin your league?

cnk_soccer

Offline

Board footer

Powered by FluxBB