A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2005-September/345827.html below:

Sniffing Text Files

Sniffing Text Files Sniffing Text FilesDavid Pratt fairwinds at eastlink.ca
Fri Sep 23 11:07:18 EDT 2005
Hi Skip. Thank you for your reply. This is helpful and I am glad I put 
this to the list. There are some really good ideas that will help me 
come up with something good to use.

Regards,
David


On Friday, September 23, 2005, at 11:14 AM, skip at pobox.com wrote:

>
>     David> I realize CSV module has a sniffer but it is something that 
> is
>     David> limited more or less to delimited files.
>
> Sure.  How about:
>
>     def sniff(fname):
>         if open(fname).read(4) == "<xml":
>             return "xml"
>         else:
>             # assume csv - use its sniffer to generate a dialect
>             return d
>
> Of course, as the number of file formats grows, you'll need to expand 
> the
> logic.  You can also run the file(1) command and see what it says.  I 
> seem
> to recall someone asking about the equivalent to file(1) implemented in
> Python awhile back.
>
> -- 
> Skip Montanaro
> Katrina Benefit Concerts: http://www.musi-cal.com/katrina
> skip at pobox.com
>

More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4