<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'><div dir='ltr'>
<br>Hi,<br><br>i got a csv file that i need to modify and create a new one,  i have no problem to read mi 'test.cvs' which is the source file but when i try to create a new one with the modifications i only got the first row in my 'out.csv' file.  I think there is somethng wrong in my loop because i can't  put into the rest.   <br><br><br>this is my an example of source file:<br>[test.csv]<br>Name;Lastname;Age;ContractDate;PhoneNumber<br>John;Smith;20110128 105840;33611111111<br>Mike;Brown;20110128 105842;33622222222<br>James;Ryan;20110128 105850;33633333333<br>Barry;Jackson;20110128 105847;33644444444<br><br><br>[here my code:]<br><br>import sys<br>import csv<br>import os<br>import glob<br>import time<br><br>dir_cdr = "/tmp"<br>#loop to find files csv in a directory and read thoses files<br>for cdr_files_in in glob.glob(os.path.join(dir_cdr, '*.csv') ):<br>        file_source = open(cdr_files_in, 'r')<br>        reader = csv.reader(file_source, delimiter=';', quoting=csv.QUOTE_NONE)<br>        try:<br>                for data in reader:<br>                        if data:<br>                                firstname = data[0]<br>                                lastname = data[1]<br>                                date_source = data[2]<br>                                phone = data[3]<br>                                #Date to epoch<br>                                timestamp=int(time.mktime(time.strptime(date_cdr, "%Y%m%d %H%M%S")))<br>                                fout = open("out.csv", "w")<br>                                print >>fout, lastname, firstname, timestamp, phone<br>                                fout.close()<br>                                sys.exit()<br>                file_source.close()<br>        except csv.Error, e:<br>                print e<br>                file_source.close()<br>                sys.exit('file %s, line %d: %s' % (file_source, reader.line_num, e)<br><br>[out.csv]<br>Smith John 1296208720 33611111111<br><br><br>Could you help me?<br><br>Best Regards,<br>Miguel<br><br>                                         </div></body>
</html>