openerp - Python Import text file -
i'm used below code import text document.
class text_based_attendance(osv.osv): def text_files_upload(self, cr, uid, ids, context=none): attendance_v={} attendance_obj = self.pool.get('text.based.attendance') print('text files going upload') open("/home/priyan/desktop/store/hr_module/attendance/savefile.txt") f: c = csv.reader(f, delimiter=':', skipinitialspace=true) line in c: name=line[0]
here text document text (finger print machine output text file)
09d043543011301292:0834*0073*:3:5:g 09d043543011301292:1744*0073*:3:5:g
here shows error
2013-08-16 11:16:00,792 5291 error bell_hr_beta openerp.osv.osv: uncaught exception traceback (most recent call last): file "/home/priyan/hr_openerp/openerp-7.0/openerp/osv/osv.py", line 131, in wrapper return f(self, dbname, *args, **kwargs) file "/home/priyan/hr_openerp/openerp-7.0/openerp/osv/osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) file "/home/priyan/hr_openerp/openerp-7.0/openerp/osv/osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) file "/home/priyan/hr_openerp/openerp-7.0/openerp/addons/hr_attendance/hr_attendance.py", line 227, in text_files_upload line in c: error: new-line character seen in unquoted field - need open file in universal-newline mode?
edit change methods below file read , gives error when second line read
with open("/home/priyan/desktop/store/hr_module/attendance/savefile.txt",'ru') f:
new error
2013-08-16 11:22:05,972 5382 error bell_hr_beta openerp.osv.osv: uncaught exception traceback (most recent call last): file "/home/priyan/hr_openerp/openerp-7.0/openerp/osv/osv.py", line 131, in wrapper return f(self, dbname, *args, **kwargs) file "/home/priyan/hr_openerp/openerp-7.0/openerp/osv/osv.py", line 197, in execute res = self.execute_cr(cr, uid, obj, method, *args, **kw) file "/home/priyan/hr_openerp/openerp-7.0/openerp/osv/osv.py", line 185, in execute_cr return getattr(object, method)(cr, uid, *args, **kw) file "/home/priyan/hr_openerp/openerp-7.0/openerp/addons/hr_attendance/hr_attendance.py", line 228, in text_files_upload name=line[0] indexerror: list index out of range
open("/home/priyan/desktop/store/hr_module/attendance/savefile.txt",'ru') f: c = csv.reader(f, delimiter=':', skipinitialspace=true) line in c: if line: name=line[0]
its sorted.i check every times when new lines comes ok
:-)
Comments
Post a Comment