def strip_first_row(in,out):
      in=open(in,'rb')
      out=open(out,'wb')
      for i,row in enumerate(in):
           if i>0: out.write(row)

def add_header(columns=['table.field1',table.field2','etc']):
      in=open(in,'rb')
      out=open(out,'wb')
      out.write(', '.join(columns)
      for i,row in enumerate(in): out.write(row)

Hope this helps.

Massimo

On Nov 20, 1:22 am, seeker <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I notice from the manual that one exports data to csv by using str()
> and imports csv data using import_from_csv_file.
> This produces/uses a csv file with the 1st row having column names in
> the format table.field.
>
> My situation:
> ==========
> I have 3 systems:
> (a) Web2Py application that communicates with both the other systems
> using csv files.
> (b) and (c) two separate legacy systems that communicate with each
> other and with (a) using csv files.
>
> The problems are:
> (1) System (a) uses and produces csv files without a header row.
> (2) System (b) uses a header row, but the column names are not in the
> format that web2py produces/uses.
>
> Solution???:
> ==========
> Would it be possible to change the way web2py produces csv files?
>
> - I am new to Python, so I don't know whether str() can be changed/
> overridden to take optional parameters: 'has_header' (true/false,
> default=true) and 'labels' (dictionary with column/label pairs).
>
> - Also change import_from_csv_file to take additional parameters:
> 'has_header' (true/false, default=true) and 'labels' (dictionary with
> column/label pairs).
>
> Thanks for any help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to