SemanticImportString

SemanticImportString["string"]

attempts to import a string semantically to give a Dataset object.

SemanticImportString["string",type]

attempts to interpret all elements in the string as being of the specified type.

SemanticImportString["string",{type1,type2,}]

attempts to interpret elements in successive columns as being of the specified types.

SemanticImportString["string",col1->type1,col2->type2,]

attempts to interpret elements in the named columns as being of the specified types.

SemanticImportString["string",typespec,form]

puts the result in the specified form.

Details and Options

Examples

open allclose all

Basic Examples  (6)

Import a string semantically:

Import a string as a single column of strings:

Import a string with the specified column types:

Import only some columns of a string, in the specified format, using column numbers:

Import only some columns of a string, in the specified format, using column names:

Import a string as a list of named rows:

Scope  (4)

Import a string using the given delimiter:

Specify that the first line of the string to import is a header:

Specify that the first and third lines of the given string should be skipped:

Return missing values with the form "Unknown" in the special form Missing["UnknownData"]:

Options  (12)

Delimiters  (2)

Specifying the delimiter determines how values are separated:

Import semicolon-delimited values instead:

Delimiters within quotations are ignored:

HeaderLines  (2)

If a header is detected, the first element in a column is used:

When a header is not detected, the header is an index within a string (such as "column1", "column2"):

Specify the number of header lines explicitly:

MissingDataRules  (4)

Replace strings that start with "no" by a missing zero:

Match inputs by regular expression:

Lists of lists of rules are applied column by column:

Rules are applied before interpretation:

ExcludedLines  (1)

Specify lines that should not be processed:

ColumnSpans  (3)

Specify where to split columns by the positions of the last characters in each column:

ColumnSpans automatically removes delimiters at column boundaries:

Delimiters within columns are ignored:

Applications  (3)

Import a list of quantities as a Dataset object:

Import quantities as an array:

Import countries:

Get the contents of a file:

Apply any string transformations to the input file. In this case, the full text is simply set to uppercase:

Import the data contained in the string:

Import the price column only:

Possible Issues  (4)

The interpretation of data depends upon its context. Without further context, "12,3" is interpreted as a date:

In the context of the value "45,4", which is not a valid date, "12,3" is interpreted as two integers:

SemanticImportString, unlike SemanticInterpretation, does only simple, quick inferences. SemanticImportString imports state names as strings:

SemanticInterpretation imports state names as Entity objects:

Automatic type selection chooses from a smaller set of interpretations rather than specifying a type explicitly:

An Automatic type specifies an automatically selected number of columns:

An {Automatic} type specifies a single column of automatically selected type:

Automatic in a type list applies to the corresponding column sequentially:

Introduced in 2014
 (10.0)