2
$\begingroup$

Why does Export["str", str, "Table"] not evaluate to an error, where str is any expression?

$\endgroup$

closed as off-topic by m_goldberg, MarcoB, Jason B., LCarvalho, Carl Lange Feb 27 at 8:56

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, MarcoB, Jason B., LCarvalho, Carl Lange
If this question can be reworded to fit the rules in the help center, please edit the question.

  • $\begingroup$ What happens if you evaluate Import[ "str", "Table"] immediately after? $\endgroup$ – Jason B. Feb 22 at 19:26
  • $\begingroup$ @Jason B {{"str"}} which, to me, is equally weird; $\endgroup$ – yosimitsu kodanuri Feb 22 at 19:36
  • 2
    $\begingroup$ This seems like expected behavior. The doc page says "The Wolfram Language automatically transforms arbitrary expressions to a list of lists when exporting to the "Table" format." - if you need to restrict this to only tabular data you could write a small wrapper function that checks that the input is the right form and then calls Export $\endgroup$ – Jason B. Feb 22 at 19:40
  • 4
    $\begingroup$ "str" is a perfectly good path relative to the current directory. $\endgroup$ – John Doty Feb 22 at 20:04
  • 1
    $\begingroup$ Export["str", ... , "Table"] exports to the file "str" (without file extension) in Directory[]. So the full file path is FileNameJoin[{Directory[], "str"}]. Notice also that a single symbol in the second argument will converted to a string and then written to file. Run Import["str", "Text"] in order to see the verbatim file content. Hence, it is Import that converts to a table, not export. $\endgroup$ – Henrik Schumacher Feb 22 at 20:16

Browse other questions tagged or ask your own question.