Attachment 'csv_python_module.diff'

Download

   1 --- CSV.py	Wed Nov  3 17:15:35 2004
   2 +++ /home/tiago/lib/python/MoinMoin/processor/CSV.py	Wed Nov  3 22:21:47 2004
   3 @@ -8,9 +8,13 @@
   4  
   5  Dependencies = []
   6  
   7 +import csv
   8 +
   9  def process(request, formatter, lines):
  10      # parse bangpath for arguments
  11      exclude = []
  12 +    separator=';'
  13 +    
  14      for arg in lines[0].split()[1:]:
  15          if arg[0] == '-':
  16              try:
  17 @@ -19,6 +23,8 @@ def process(request, formatter, lines):
  18                  pass
  19              else:
  20                  exclude.append(idx-1)
  21 +	else:
  22 +    	    separator=arg
  23  
  24      # remove bang path, create output list
  25      del lines[0]
  26 @@ -32,15 +38,16 @@ def process(request, formatter, lines):
  27          first = 0
  28          del lines[0]
  29  
  30 +    reader = csv.reader(lines, delimiter=separator, quotechar='\'', escapechar='"')
  31      output.append(formatter.table(1))
  32 -    for line in lines:
  33 +    
  34 +    for line in reader:
  35          output.append(formatter.table_row(1))
  36 -        cells = line.split(';')
  37 -        for idx in range(len(cells)):
  38 +        for idx in range(len(line)):
  39              if idx in exclude: continue
  40              output.append(formatter.table_cell(1))
  41              if first: output.append(formatter.strong(1))
  42 -            output.append(formatter.text(cells[idx]))
  43 +            output.append(formatter.text(line[idx]))
  44              if first: output.append(formatter.strong(0))
  45              output.append(formatter.table_cell(0))
  46          output.append(formatter.table_row(0))

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2004-05-05 21:34:20, 10.3 KB) [[attachment:AbcMusic.py]]
  • [get | view] (2004-04-15 07:19:38, 3.4 KB) [[attachment:DataLanguage.py]]
  • [get | view] (2004-04-15 20:23:33, 2.5 KB) [[attachment:GANTT-1.2.1.py]]
  • [get | view] (2003-12-07 18:15:55, 2.4 KB) [[attachment:GANTT.py]]
  • [get | view] (2004-07-29 15:04:28, 12.1 KB) [[attachment:IndentTable.py]]
  • [get | view] (2004-10-05 13:12:16, 10.6 KB) [[attachment:MySQL.py]]
  • [get | view] (2004-03-27 18:55:57, 3.7 KB) [[attachment:SimpleTable.py]]
  • [get | view] (2003-12-07 18:15:55, 1.5 KB) [[attachment:TextOnRight.py]]
  • [get | view] (2004-09-17 06:53:46, 3.0 KB) [[attachment:awktable-1.2.3.py]]
  • [get | view] (2004-10-28 13:55:04, 1.0 KB) [[attachment:colorer.py]]
  • [get | view] (2004-11-04 00:26:37, 1.4 KB) [[attachment:csv_python_module.diff]]
  • [get | view] (2004-04-21 18:29:38, 0.2 KB) [[attachment:html.py]]
  • [get | view] (2004-08-16 10:59:24, 4.8 KB) [[attachment:latex-1.2.3.py]]
  • [get | view] (2004-08-07 07:36:59, 3.9 KB) [[attachment:latex-cygwin.py]]
  • [get | view] (2004-04-09 17:05:33, 2.9 KB) [[attachment:latex.1.2.1.py]]
  • [get | view] (2004-02-29 16:50:13, 2.1 KB) [[attachment:latex.py]]
 All files | Selected Files: delete move to page copy to page

You are not allowed to attach a file to this page.