Contents
Show CSV
Purpose
This macro is used to show csv data as wiki table
Download & Release Notes
Download |
Release Version |
Moin Version |
Release Notes |
|
1.6 |
|
|
|
1.5.8 |
|
Syntax
[[ShowCSV]]
optional as argument the extension could be entered, default is '.csv'.
Example
[[ShowCSV]]
Example image
Copyright
License
Comment
UTF-8
As far as I see this macro is not utf-8 compatible. So it's not possible to integrate csv data with umlauts and other chars. Belive could be fixed if use some other other open method and unicode strings u"..., but well i'm just a pyton newbee.
f = codecs.open("dateiname.txt", "r", "utf-8")
-- MarcelHäfner 2007-10-09 09:42:03
yeah your are right. Sometimes I do miss thats utf-8 isn't default. We need some more lines from http://docs.python.org/lib/csv-examples.html -- ReimarBauer 2007-10-27 09:32:50
Empty Cells
I've tried this with a CSV file that contained a lot of empty cells, e.g. "a,,,d". The resulting table combined the last cell with a value and all following empty cells. Is this behavior intended? I would have expected that in this case the table just contains empty cells.
hmm, csv.reader seems not to be happy with those empty cells. I'll look in this later. Empty cells are handled very different in different programs. Can you please add an example and probably an image what happend
Ok, I have uploaded the dummy.csv file,
a screen shot displaying how the data are displayed in a spreadsheet
and a screen shot displaying the same file in my wiki using your ShowCSV macro
I can work around this by filling all empty cells with N/A or something similar. However, it would be nice if it your macro could handle this automatically. BTW: I have not tried the version you uploaded today yet. -- AnkeHeinrich 2007-10-27 12:13:00
I just updated the ShowCSV macro. No change in display regarding empty cells. -- AnkeHeinrich 2007-10-27 12:23:00
Should be fixed now -- ReimarBauer 2007-10-27 14:41:51
Thanks, that works. -- AnkeHeinrich 2007-10-27 15:42:00
Can you also take a look at the space between the table and the attachment? Seems to be a bit large. Does this depend on the number of rows? -- AnkeHeinrich 2007-10-27 15:49:00
No, see btw. which browser do you use? -- ReimarBauer 2007-10-27 18:48:24
You are right. It's browser related. On my server PC there was only IE 6 which has this problem. Everything is fine in Firefox which I usually use. -- AnkeHeinrich 2007-10-27 19:13:00
ok, sometimes its easier to talk on #moin at irc.freenode.net -- ReimarBauer 2007-10-27 19:50:45
BTW, the default extension seems to be '.csv' an not '.nas' as described above.
-- AnkeHeinrich 2007-10-12 07:39:14
yeah your are right this happen by copy and paste -- ReimarBauer 2007-10-13 12:22:02
ShowCSV2
I changed the macro a bit; so it's now possible to add some delimiter and chose the extension. It works with Python 2.5 and MoinMoin 1.7.x.
Example:
<<ShowCSV2(delimiter=semicolon,extension=csv)>>
Parameters:
extension = <extension name>
delimiter = <mark name>
- possible values are: semicolon, comma, pipe
Download: ShowCSV2.py
I'm "newbie" to python coding; so mercy for my poor code, thx!
Copyrights
Do what you want; maybe some stuff/ideas could be used for the "official" macro. -- MarcelHäfner 2008-07-21 20:03:50
Discussion
in 1.7 the csv parser can be used.
or
it can also be used to parse attachments
dummy.csvWhile I was writing the macro JohannesBerg has extended the old csv parser. Later on we have added the sniffer for getting the delimiter. I think the macro is obsolete in 1.7. I have to apologize for not adding this note earlier, I just forgot it.
Anyway if macros are refactored to 1.7 the argument parser should be involved. That makes it much easier. Look for examples at the macro EmbedObject of 1.7 or MacroMarket/HelloWorld-1.7.
-- ReimarBauer 2008-07-21 20:51:36
thx! but this syntax doesn't work in my 1.7.1. I don't know. I did nothing about embended mimetype to the config... just not working with my wiki, but tested successfully on this wiki. my "error" message is like Current configuration does not allow embedding of the file beispiel.csv because of its mimetype application/octet-stream - maybe a tip / hint where to look for would be great (see here: http://www.heavy.ch/auslastung.log). bye -- MarcelHäfner 2008-07-21 22:49:37
This likly depends on the configuration file /etc/mime.types. Search for text/csv and add your extension if it is not there. I think we do have already a feature request about overwriting the mimetype definition because of to different definitions in this file. -- ReimarBauer 2008-07-22 05:53:28
what do I do if I have no access to the /etc; only running a "user" local apache mod_wsgi with moinmoin (and a main apache instance proxy back the whole stuff). I tried to add AddType text/csv csv and activated the modules mime_module in my local apache conf. no results! well maybe the main apache need to add this mimetype. sure I can ask the provider; but.. any ideas? thanks for your support! bye MarcelHäfner
Thanks to ReimarBauer I found a solution: Just patch your wikiutil.py file and search for MIMETYPES_MORE and add there something like:
'.csv': 'text/csv',
bye -- MarcelHäfner 2008-07-22 20:13:15