1
$\begingroup$

I want to import a TSV file where many of the columns have entries like 00966.

When I use Import[path, "tsv"] to import this file, such entries get converted to integers (e.g. 00966 gets read as the integer 966).

I want instead to preserve those entries as strings. IOW, 00966 should be read in as the string "00966", not the integer 966.

I know that SemanticImport provides ways to specify the types for individual columns, but I want to avoid SemanticImport at all cost, because I've found it to be horribly buggy.

Is there some way to get Import to just read each line as a list of strings (by doing nothing more to each line than stripping the trailing newline, and splitting the remainder at the tabs)?

$\endgroup$
1
  • 3
    $\begingroup$ Does the option "Numeric"->False, help? That is, does Import[path, "tsv", "Numeric"->False] work? $\endgroup$
    – kglr
    Commented Jul 22, 2017 at 15:24

1 Answer 1

1
$\begingroup$

Documentation >> TSV >> Options:

  • With "Numeric"-> False, numbers will be imported as strings in the form they appear in the file.

So, you can use

Import[path, "tsv", "Numeric" -> False]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.