On Thu, Nov 20, 2008 at 21:48, mdipierro <[EMAIL PROTECTED]> wrote: > > 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) > clean and simple! collected!
> 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. -- http://zoomquiet.org''' 过程改进乃是催生可促生靠谱的人的组织! PE keeps evolving organizations which promoting people be good!''' [HR]金山软件常年招聘大量Py/C++人才! https://groups.google.com/group/python-cn/web/ot-py-c 简历直投俺就好;-) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py Web Framework" group. To post to this group, send email to web2py@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---