FileFormat
Listing of Formats »FileFormat[source]
attempts to determine what Import format could be used to import the file corresponding to source.
FileFormat[source,{"fmt1","fmt2",…}]
returns the first "fmti" that can be used to import source.
Details and Options
- FileFormat returns a format name of the type used by Import.
- In FileFormat[source,…], source can be any of the following:
-
"file" or File["file"] file name, searched for on $Path "url" or URL["url"] HTTP, HTTPS or FTP URL - FileFormat uses heuristic methods, and may not give correct results, particularly for shorter files.
- FileFormat does not verify that Import would succeed if applied to source.
- FileFormat gets clues from both names of files and properties of files recorded in the filesystem, but bases the final result it returns only on the actual contents of files.
- The following option can be specified:
-
MaxItems Automatic maximum number of items to return - FileFormat[url] accepts the following URLDownload options:
-
Authentication None authentication information to send CookieFunction Automatic function to apply to each cookie received ConnectionSettings Automatic speed and other settings for the connection FollowRedirects True whether to follow HTTP redirects Interactive True whether to allow interactive authentication dialogs TimeConstraint Infinity time to wait for a response VerifySecurityCertificates True whether to verify SSL security certificates
Examples
open allclose allBasic Examples (2)
Scope (7)
Source (3)
Determine the Import format of a file:
FileFormat gives the format name used by Import:
Determine the Import format of a URL:
Format (4)
Check if a file might be "GZIP" compressed:
If not, None is returned:
Check if the format of the "GZIP" compressed file might be "3DS":
Check if a file might be one of several formats:
FileFormat returns the first format that matches:
Options (1)
Properties & Relations (2)
A file name could match different formats:
FileFormat uses this list as a starting point to make a guess:
It is possible to create a file with an incorrect extension. Create a PNG file with a .jpg extension:
FileNameToFormatList only looks at the file name:
FileFormat uses more sophisticated heuristics to determine the correct format:
Possible Issues (1)
FileFormat uses heuristics, which may not always be accurate, like giving "CSV" for an "MBOX" file:
Text
Wolfram Research (2007), FileFormat, Wolfram Language function, https://reference.wolfram.com/language/ref/FileFormat.html (updated 2020).
CMS
Wolfram Language. 2007. "FileFormat." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/FileFormat.html.
APA
Wolfram Language. (2007). FileFormat. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FileFormat.html