Import
Usage
Notes
Additional Information
Many Import formats have private options that are specified using the option ConversionOptions: Import["file", "format", ConversionOptions -> {opts}]. BMP Import supports Windows device-independent bitmaps that are compressed using run-length encoding. CSV The following options can be given:
| "CurrencyTokens" | {{"$", " ", " ", " "}, {"c", " ", "p", "F"}} | recognized currency strings | | "DateStyle" | "American" | format of dates | | "DateSeparator" | "/" | string that delimits parts of dates | | "EmptyField" | "" | determines how an empty field should be converted | | "FieldSeparator" | "," | string that delimits elements | | "NumberSigns" | {"-", "+"} | strings used to indicate positive and negative signs | | "NumberPoint" | "." | decimal point string | | "Numeric" | True | determines whether fields that represent numbers are to be converted into numeric quantities | | "TwoDigitYearFunction" | None | how two-digit years in date fields should be interpreted |
• Setting "Numeric" to False stores numbers as their string textual representations. • The option "DateStyle" can be set to the values "American", "European", or "Scientific". • A field is considered to be a date if it consists of three adjacent, forward slash-delimited integers of which the month, day, and year values appear to be reasonable. Months must be between 1 and 12 inclusive. The day must not lie outside the valid range of days for the given month. A year's validity can be determined indirectly by "TwoDigitYearFunction". • A date field will be broken into a list of the form {year, month, day}. • The option "TwoDigitYearFunction" can be set to None, Automatic, or an arbitrary function. • Setting the "TwoDigitYearFunction" to its default value of None keeps the date field from being interpreted as a date if the year has only two digits. • When "TwoDigitYearFunction" is set to Automatic, 1900 is added to the year and the field is interpreted as a date. • User-defined functions for "TwoDigitYearFunction" must return Integer values. DICOM The following options can be given:
| "DataDictionary" | Automatic | determines the names used for Data Element Tags | | "Verbose" | False | determines the format and content of the output | | "ImplicitVRs" | Automatic | determines the form used to import data elements with implicit Value Representation |
• Import supports files in the DICOM file format as specified in Section PS 3.10 of the DICOM standard and the ACR/NEMA 2.0 file format. • The ConversionOption "Verbose" determines the form of the output. • With "Verbose" False, the output is a Graphics expression created from the Pixel Data and Overlays. • With "Verbose" True, the output is a list of Data Elements of the form {DataElementTag value, ... }. • Pixel Data for most JPEG Transfer Syntaxes (all except Baseline Encoding, 1.2.840.10008.1.2.4.50) is not parsed. With "Verbose" False, the output is $Failed. With "Verbose" True, the Pixel Data is a JPEG string. • The ConversionOption "DataDictionary" determines the names used for Data Element Tags when "Verbose" True. • With "DataDictionary" Automatic, all Data Elements Tags in Section PS 3.6 of the DICOM Standard are replaced with string names. All other Data Element Tags are left as {"Group Number", "Element Number"} pairs. • With "DataDictionary" None, all Data Elements Tags are left as {"Group Number", "Element Number"} pairs. • A different set of names can be set using "DataDictionary" {{"Group Number", "Element Number"} "name", ... }. • The ConversionOption "ImplicitVRs" determines how a Data Element Value is parsed when "Verbose" True and the Data Elements use Implicit Value Representations (VRs). • If the Data Elements use Explicit VR, then the VR in the file will be used and the setting for "ImplicitVRs" is ignored. • With "ImplicitVRs" Automatic, all Implicit VRs in section PS 3.6 of the DICOM Standard are used. All other Data Elements are parsed with an unknown ( "UN") VR. • A different set of Implicit VRs can be set using "ImplicitVRs" {{"Group Number", "Element Number"} "vr", ... }. • Allowed VRs include "AE", "AS", "AT", "CS", "DA", "DS", "DT", "FL", "FD", "IS", "LO", "LT", "OB", "OW", "PN", "SH", "SL", "SQ", "SS", "ST", "TM", "UI", "UL", "UN", "US", and "UT". ExpressionML The following option can be given:
| "WrapperFunction" | Identity | function to apply to imported expression |
• See also the options listed for "SymbolicXML". FITS The following option can be given:
| "Verbose" | False | determines the format and content of the output |
• The option "Verbose" determines whether header information is imported. It also determines the format of the imported data. • With "Verbose" False, header information is not imported. • With "Verbose" False, data is formatted as a list of matrices, even if the data comes from multiple Header Data Units (HDUs). This allows for easy plotting by mapping the data with functions like ListDensityPlot and ListContourPlot. • With "Verbose" True, import returns a list of HDUs. Each HDU is a list containing a header and a data unit. • With "Verbose" True, each header is a list of entries of the form _String {"Value" _, "Comment" _String}. This allows programmatic access to values and comments in the headers. • The value of a header entry named ent can be extracted from a header named head with the following: "Value"/.(ent/.head). The comment can be extracted with "Comment"/.(ent/.head). • With "Verbose" True, data is not returned as a list of matrices, but as tensors paired in lists with their headers. A 0-dimensional tensor is represented by Null. • The primary HDU and IMAGE extensions are imported as integer or real data. • ASCII table extensions are imported as string data. • Other extensions are not supported. GIF The following options can be given:
| "ColormapOutput" | True | determines how the Raster data is imported | | "ImageIndex" | Automatic | selects certain frames of an animated GIF |
• The option "ColormapOutput" determines whether a GIF is imported as a Raster graphics primitive with a color map ColorFunction and a matrix of indices into the color map, or whether the imported Raster graphics primitive contains a normal matrix of sample values. A grayscale image will import without the use of a color map ColorFunction. • If the GIF is an animated GIF with multiple frames, "ImageIndex" -> i will select a particular frame to import. "ImageIndex" -> { , , ... } will select a list of frames from the animated GIF. By default, all frames of an animated GIF are imported. HarwellBoeing Import of "HarwellBoeing" formatted sparse matrices must be done by explicitly including the format keyword "HarwellBoeing", i.e., in the form Import["file", "HarwellBoeing"]. HDF/HDF5 The following option can be given:
| "DatasetSelection" | 1 | determines which dataset is imported |
• HDF/HDF5 files can contain multiple datasets in a single file. By default, the first dataset in an HDF file is imported. "DatasetSelection" -> i will attempt to import the dataset at index i. "DatasetSelection" -> string will attempt to find a dataset named with label string. "DatasetSelection" -> Information will not import the datasets in the file but will instead return a list of length equal to the number of datasets in the file and contain information about the format types, names, and dimensions of the datasets. • Import of HDF currently only supports the "scientific datasets" SDS interface. • If a dataset in an HDF5 file is compressed with GZIP or SZIP, it will be automatically uncompressed. JPEG The following options can be given:
| "ColorReduction" | None | determines whether color reduction occurs when importing | | "ColorReductionDither" | "Floyd-Steinberg" | specifies dithering method used with color reduction | | "ColorReductionPalette" | Automatic | determines colors in the color reduced image | | "Colorspace" | Automatic | specifies what color space is used for the imported image |
• Although the JPEG format is not stored as a color-mapped image, Import can color reduce or quantize the JPEG as it is being imported. By default, no color reduction is done. • Using a "ColorReductionDither" method can provide better resulting images once a color map is chosen by dithering the resulting image. "ColorReductionDither" -> "Ordered" provides relatively fast and medium-quality dithering, while "ColorReductionDither" -> "Floyd-Steinberg" provides the best-quality error-diffusion dithering, requiring more time and memory. "ColorReductionDither" -> None will perform no dithering on the imported image. • "ColorReduction" -> "Fixed" chooses evenly spaced colors from a color space, which may not pick the most optimal colors for the image. "ColorReduction" -> "Adaptive" uses a median-cut algorithm to choose the optimal set of colors for an image. • "ColorReductionPalette" -> Automatic will choose an adaptive set of at most 256 colors. "ColorReductionPalette" -> n will choose at most n colors for the color palette. "ColorReductionPalette" -> { , , ... } specifies a list of color directives to use to color reduce the image. The values for  must be CMYKColor, GrayLevel, Hue, or RGBColor directives. The number of colors chosen for "ColorReductionPalette" must be between 2 and 256. • The following example produces an image using a color map of "browser safe" 216 colors: Import["file.jpg", "JPEG", ConversionOptions -> {"ColorReduction" -> "Fixed", "ColorReductionPalette" -> 216}]. • Color reduction of JPEG images only applies to JPEG images with three color components. If you are producing these JPEG images yourself, you can force the use of three color components with Export and "Colorspace" -> "RGBColor": Export["file.jpg", gr, "JPEG", ConversionOptions->{"Colorspace" -> RGBColor}]. • The option "Colorspace" can be explicitly set to RGBColor or GrayLevel to force the resulting imported image to a specific color space. List The following options can be given:
| "CurrencyTokens" | {{"$", " ", " ", " "}, {"c", " ", "p", "F"}} | recognized currency strings | | "DateStyle" | "American" | format of dates | | "DateSeparator" | "/" | string that delimits parts of dates | | "NumberSigns" | {"-", "+"} | strings used to indicate positive and negative signs | | "NumberPoint" | "." | decimal point string | | "ListSeparators" | {"\r","\n", "\t", " "} | list of strings that delimit rows and columns | | "TwoDigitYearFunction" | None | how two-digit years in date fields should be interpreted |
• The options of the List format act the same as the options of the Table format. MAT Import supports versions 4 and 5 of the MAT format. MathML The following option can be given:
| "WrapperFunction" | Identity | function to apply to imported expression |
• See also the options listed for "SymbolicXML". MTX Import supports files in the MatrixMarket exchange formats described at math.nist.gov/MatrixMarket/formats.html#MMformat. When the file is in MatrixMarket coordinate format, the result will be a SparseArray. When the file is in MatrixMarket array format, the result will be a PackedArray. MPS Import of "MPS" covers two standards, MPS optimization problems and Mathematica PostScript. Using the "MPS" format determines the file type and then does the appropriate import. The following option can be given when importing MPS optimization problems:
| "FreeFormat" | False | specifies whether fields are positioned freely in the file or in the standard fixed positions |
• With "FreeFormat" False, the data file can have up to six fields in predefined positions. • With "FreeFormat" True, the data entries do not have to reside at predefined positions. A contiguous sequence of non-whitespace characters is treated as a field. NotebookML The following option can be given:
| "WrapperFunction" | Identity | function to apply to imported expression |
• See also the options listed for "SymbolicXML". PBM, PGM, PPM, PNM The following options can be given:
| "CheckDepth" | True | determines whether the image color depth is checked | | "ColorReduction" | False | determines whether color reduction occurs when importing | | "ColorReductionDither" | True | determines whether to use dithering | | "ColorReductionPalette" | Automatic | determines colors in the resulting image |
• "CheckDepth" -> True will check the data on importing to see if the actual data stored in the image could be represented by a reduced color space. For example, if a PPM file contains identical red, green, and blue components for all pixels, a Raster of gray levels is imported. • Although the PBM formats are not stored as a color-mapped image, Import can color reduce or quantize the PBM as it is being imported. By default, no color reduction is done. "ColorReduction" -> True will perform color quantization. • By dithering the resulting image, "ColorReductionDither" -> True will provide better resulting images once a color map is chosen. • "ColorReductionPalette" -> Automatic will choose an adaptive set of at most 256 colors. "ColorReductionPalette" -> n will choose at most n colors for the color palette. "ColorReductionPalette" -> { , , ... } specifies a list of color directives to use to color reduce the image. The values for  must be CMYKColor, GrayLevel, Hue, or RGBColor directives. The number of colors chosen for "ColorReductionPalette" must be between 2 and 256. SDTS The following options can be given:
| "ElementSkip" | 1 | determines which elements of the data to import | | "FillValue" | -10000 | specifies what value is used for points that do not contain data |
• The option "FillValue" is used when importing nonrectangular data. Since every dataset is rectangular, there will be data points that do not correspond to any physical data. "FillValue" specifies what integer value is used in Mathematica to represent these data points. Adjusting the "FillValue" can improve the contrast with other data points when plotting the data. • The option "ElementSkip" n is an optimization which specifies to only import every   row and column of the dataset. This reduces the timing for Import and other functions acting on the imported data. This is useful when the dataset has a greater resolution than required. • Only import of Digital Elevation Models (DEM) are supported. Most DEM data in SDTS format come in gzipped tar archives. The DEM data is contained in a single file in the archive, named ????CEL0.DDF. SymbolicXML The following options can be given:
| "NormalizeWhitespace" | Automatic | whether to remove leading and trailing white space within elements and to reduce consecutive spaces to a single space | | "ReadDTD" | True | whether to read an external document type definition | | "AllowRemoteDTDAccess" | True | whether to attempt to retrieve an external DTD over a network | | "ValidateAgainstDTD" | Automatic | whether to check the validity of the document according to its DTD | | "IncludeNamespaces" | Automatic | whether to associate a namespace explicitly with each element in the symbolic XML expression | | "IncludeEmbeddedObjects" | None | which embedded objects (of "Comments" and "ProcessingInstructions") to include in the symbolic XML expression | | "IncludeDefaultedAttributes" | False | whether to make defaulted attribute values explicit in the symbolic XML expression | | "AllowUnrecognizedEntities" | Automatic | whether to allow parsing to work around unrecognized entities in the XML document | | "PreserveCDATASections" | False | whether to preserve CDATA sequences as special objects in the symbolic XML expression instead of simply expressing them as character sequences |
Table The following options can be given:
| "CurrencyTokens" | {{"$", " ", " ", " "}, {"c", " ", "p", "F"}} | recognized currency strings | | "DateStyle" | "American" | format of dates | | "DateSeparator" | "/" | string that delimits parts of dates | | "NumberSigns" | {"-", "+"} | strings used to indicate positive and negative signs | | "NumberPoint" | "." | decimal point string | | "TableSeparators" | {{"\r","\n"}, {" ", "\t"}} | list of strings that delimit rows and columns | | "TwoDigitYearFunction" | None | how two-digit years in date fields should be interpreted |
• The option "DateStyle" can be set to the values "American", "European", or "Scientific". • A field is considered to be a date if it consists of three adjacent, forward slash-delimited integers of which the month, day, and year values appear to be reasonable. Months must be between 1 and 12 inclusive. The day must not lie outside the valid range of days for the given month. A year's validity can be determined indirectly by "TwoDigitYearFunction". • A date field will be broken into a list of the form {year, month, day}. • The option "TwoDigitYearFunction" can be set to None, Automatic, or an arbitrary function. • Setting the "TwoDigitYearFunction" to its default value of None keeps the date field from being interpreted as a date if the year has only two digits. • When "TwoDigitYearFunction" is set to Automatic, 1900 is added to the year and the field is interpreted as a date. • User-defined functions for "TwoDigitYearFunction" must return Integer values. TIFF The following options can be given:
| "CheckDepth" | True | checks image color depth | | "ImageIndex" | Automatic | selects certain images from a TIFF |
• "CheckDepth" -> True will check the data on importing to see if the actual bit depth of the TIFF is smaller than one byte per image sample, and this can result in a Raster with integer values scaled to a more exact representation of what was stored in the TIFF. For example, a 4-bit TIFF image would be imported as a Raster with a matrix of integer values between 0 and 15 and not the normal 0 to 255 associated with a byte of image sample information. • If the TIFF contains multiple images, "ImageIndex" -> i will select a particular image to import. "ImageIndex" -> { , , ... } will select a list of images from the TIFF. By default, all images of a TIFF are imported. TSV The following options can be given:
| "CurrencyTokens" | {{"$", " ", " ", " "}, {"c", " ", "p", "F"}} | recognized currency strings | | "DateStyle" | "American" | format of dates | | "DateSeparator" | "/" | string that delimits parts of dates | | "EmptyField" | "" | determines how an empty field should be converted | | "NumberSigns" | {"-", "+"} | strings used to indicate positive and negative signs | | "NumberPoint" | "." | decimal point string | | "Numeric" | True | determines whether fields that represent numbers are to be converted into numeric quantities | | "TwoDigitYearFunction" | None | how two-digit years in date fields should be interpreted |
• Setting "Numeric" to False stores numbers as their string textual representations. • The option "DateStyle" can be set to the values "American", "European", or "Scientific". • A field is considered to be a date if it consists of three adjacent, forward slash-delimited integers of which the month, day, and year values appear to be reasonable. Months must be between 1 and 12 inclusive. The day must not lie outside the valid range of days for the given month. A year's validity can be determined indirectly by "TwoDigitYearFunction". • A date field will be broken into a list of the form {year, month, day}. • The option "TwoDigitYearFunction" can be set to None, Automatic, or an arbitrary function. • Setting the "TwoDigitYearFunction" to its default value of None keeps the date field from being interpreted as a date if the year has only two digits. • When "TwoDigitYearFunction" is set to Automatic, 1900 is added to the year and the field is interpreted as a date. • User-defined functions for "TwoDigitYearFunction" must return Integer values. XLS The following option can be given:
| "EmptyField" | "" | determines how an empty field should be converted |
XML See the options listed for "SymbolicXML".
|