<> = Show CSV = == Purpose == This macro is used to show csv data as wiki table == Download & Release Notes == || Download || Release Version || Moin Version || Release Notes || || [[attachment:ShowCSV-1.6.py]] || || 1.6 || || || [[attachment:ShowCSV.py]] || || 1.5.8 || || == Syntax == {{{ [[ShowCSV]] }}} optional as argument the extension could be entered, default is '.csv'. == Example == {{{ [[ShowCSV]] }}} Example image {{attachment:showcsv.png}} == Copyright == ReimarBauer == 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 <> 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 <> == 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 [[attachment:dummy.csv]] file, a screen shot displaying how the data are displayed in a spreadsheet {{attachment:CSVinSpreadsheet.jpg}} and a screen shot displaying the same file in my wiki using your ShowCSV macro {{attachment:CSVinMoinWithShowCSVMacro.jpg}} 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 <> I just updated the ShowCSV macro. No change in display regarding empty cells. -- AnkeHeinrich <> ''Should be fixed now '' -- ReimarBauer <> Thanks, that works. -- AnkeHeinrich <> 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 <> No, see {{attachment:example.png}} btw. which browser do you use? -- ReimarBauer <> 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 <> ok, sometimes its easier to talk on #moin at irc.freenode.net -- ReimarBauer <> BTW, the default extension seems to be '.csv' an not '.nas' as described above. -- AnkeHeinrich <> yeah your are right ''this happen by copy and paste'' -- ReimarBauer <> = 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: {{{ <> }}} Parameters: * extension = * delimiter = <
> possible values are: semicolon, comma, pipe Download: [[attachment:ShowCSV2.py]] {i} 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 <> = Discussion = in 1.7 the csv parser can be used. {{{#!csv 1;1 2;3 }}} or {{{#!csv 1,1 2,3 }}} it can also be used to parse attachments {{attachment:dummy.csv}} While 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 <> * 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 <> ''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 <> * 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 <>