got*_*nes 29
您可以尝试类似下面的内容,但仅仅因为您从中获得方言csv.Sniffer
确实不足以保证您拥有有效的CSV文档.
csv_fileh = open(somefile, 'rb')
try:
dialect = csv.Sniffer().sniff(csv_fileh.read(1024))
# Perform various checks on the dialect (e.g., lineseparator,
# delimiter) to make sure it's sane
# Don't forget to reset the read position back to the start of
# the file before reading any entries.
csv_fileh.seek(0)
except csv.Error:
# File appears not to be in CSV format; move along
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
16801 次 |
最近记录: |