diff options
| author | Kenneth Reitz <me@kennethreitz.com> | 2010-10-04 11:55:48 -0400 |
|---|---|---|
| committer | Kenneth Reitz <me@kennethreitz.com> | 2010-10-04 11:55:48 -0400 |
| commit | 520a1986d72f4baad3607911db0023967e1b9246 (patch) | |
| tree | 07161b0af50e3b828a2638750e390555af6474bc /tablib/formats/_csv.py | |
| parent | c223dfbdf12bfa9ec6458184b83ac3e458efb185 (diff) | |
| parent | 1ea793112cdbc7328e37138e12aa0bfa8cedd9ea (diff) | |
| download | tablib-0.8.3.tar.gz | |
Merge branch 'release/0.8.3'v0.8.3
Diffstat (limited to 'tablib/formats/_csv.py')
| -rw-r--r-- | tablib/formats/_csv.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tablib/formats/_csv.py b/tablib/formats/_csv.py index 8b19da7..27d2e0d 100644 --- a/tablib/formats/_csv.py +++ b/tablib/formats/_csv.py @@ -40,3 +40,12 @@ def import_set(dset, in_stream, headers=True): dset.headers = row else: dset.append(row) + + +def detect(stream): + """Returns True if given stream is valid CSV.""" + try: + rows = dialect = csv.Sniffer().sniff(stream) + return True + except csv.Error: + return False
\ No newline at end of file |
