DIF (.dif)
DIF (.dif)
Background & Context
-
- DIF spreadsheet format.
- Standard file format for spreadsheets and other tabular data.
- Used as an exchange format for spreadsheet applications.
- DIF is an acronym for Data Interchange Format.
- Plain text format.
- Stores a single spreadsheet.
- Developed in 1980 as part of the VisiCalc spreadsheet software.
Import & Export
- Import["file.dif"] imports a DIF file, returning a list of lists representing the rows and columns stored in the file.
- Import["file.dif",elem] imports the specified element.
- Import["file.dif",{elem,suba,subb,…}] imports a subelement.
- The import format can be specified with Import["file","DIF"] or Import["file",{"DIF",elem,…}].
- Export["file.dif",expr] creates a DIF file from expr.
- Supported expressions expr include:
-
{v1,v2,…} a single column of data {{v11,v12,…},{v21,v22,…},…} lists of rows of data array an array such as SparseArray, QuantityArray, etc. tseries a TimeSeries, EventSeries or a TemporalData object Dataset[…] a dataset Tabular[…] a tabular object - Export["file.dif",expr] uses the InputForm of non-numeric table elements.
- See the following reference pages for full general information:
-
Import, Export import from or export to a file CloudImport, CloudExport import from or export to a cloud object ImportString, ExportString import from or export to a string ImportByteArray, ExportByteArray import from or export to a byte array
Import Elements
- General Import elements:
-
"Elements" list of elements and options available in this file "Summary" summary of the file "Rules" list of rules for all available elements - Data representation elements:
-
"Data" two-dimensional array, representing the rows and columns stored in the DIF file "EventSeries" table data as an EventSeries "Grid" table data as a Grid object "Tabular" table data as a Tabular object "TimeSeries" table data as a TimeSeries - Import and Export use the "Data" element by default.
Examples
open all close allBasic Examples (3)
Import tabular data from a DIF sample file, formatting it as a table:
Import["ExampleData/timeline.dif"]//TableFormImport["ExampleData/timeline.dif", "Summary"]Export a Tabular object to a DIF file:
tabular = Tabular[Association["RawSchema" -> Association["ColumnProperties" ->
Association["City" -> Association["ElementType" -> "String"],
"Country" -> Association["ElementType" -> "String"], "Population" ->
Association["ElementType" -> "Real64"]], "KeyColumns" -> None,
"Backend" -> "WolframKernel"], "Options" -> {MissingValuePattern -> Automatic},
"BackendData" -> Association["ColumnData" -> DataStructure["ColumnTable",
{{TabularColumn[Association["Data" -> {{3, {0, 5, 12, 18, 24}, "TokyoChicagoLondonBerlin"},
{}, None}, "ElementType" -> "String"]], TabularColumn[
Association["Data" -> {{3, {0, 5, 18, 32, 39}, "JapanUnited StatesUnited KingdomGermany"},
{}, None}, "ElementType" -> "String"]], TabularColumn[
Association["Data" -> {{8.3*^6, 2.8*^6, 7.4*^6, 3.4*^6}, {}, None},
"ElementType" -> "Real64"]]}}]]]];Export["cities.dif", tabular]Import Elements (4)
Data Representation (4)
"Data" (1)
"EventSeries" (1)
Import a DIF file as an EventSeries object:
Import["ExampleData/timeline.dif", "EventSeries"]"Tabular" (1)
Import a DIF file as a Tabular object:
Import["ExampleData/timeline.dif", "Tabular"]"TimeSeries" (1)
Import a DIF file as a TimeSeries object:
Import["ExampleData/timeline.dif", "TimeSeries"]History
Introduced in 2007 (6.0) | Updated in 2012 (9.0) ▪ 2025 (14.2) ▪ 2025 (14.3) ▪ 2026 (15.0)