1. hideki nara
  2. django-csvutils

Commits

hideki nara  committed fa996f7

TSV can be used with dialect

  • Participants
  • Parent commits 7e80d99
  • Branches default

Comments (0)

Files changed (2)

File csvutils/models.py

View file
  • Ignore whitespace
         except Exception,e:
             return rec, e
         
-    def csv_load(self,stream,header=True,encoding=None,keys=['id']):
+    def csv_load(self,stream,header=True,encoding=None,keys=['id'],dialect='excel'):
 
         if header==False:
             fieldnames = [ f.name for f in self.model._meta.fields if not isinstance(f,AutoField) ]
         else:
             fieldnames=None
 
-        for index,row in UnicodeReader.csv_enumerator(stream,fieldnames):
+        for index,row in UnicodeReader.csv_enumerator(stream,fieldnames,dialect):
             rec,e = self.from_dictrow(row,keys)
             yield index,rec,e 
 

File test/app/sample/models.py

View file
  • Ignore whitespace
             return int(val) == 1
         except:
             return False
+
+    @property
+    def address(self):
+        town = self.town.replace(u'区以下に掲載がない場合','')