This question already has an answer here:

I have a function that works with a list and outputs it. Is it possible to also get the name of the list as an argument? Right now my code is

exportPrognosisData[data_] := Export[StringJoin[ToString[HoldForm[data]], ".csv"], data] 

But the resulting file name is the list and not its title.


marked as duplicate by Kuba list-manipulation Jul 18 '16 at 13:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • $\begingroup$ Take a look at SymbolName, + its Possible Issues section. And at HoldFirst and friends. $\endgroup$ – Kuba Jul 18 '16 at 13:12
  • 1
    $\begingroup$ I would've went the other way, exportPrognosisData[data_String]:=Export[data<>".csv", ToExpression[data]]; $\endgroup$ – Jason B. Jul 18 '16 at 13:12
  • $\begingroup$ C**p, wrong tag and now I'm fully responsible for closing -.- $\endgroup$ – Kuba Jul 18 '16 at 13:17
  • 1
    $\begingroup$ @Kuba, heavy is the mouse button of one who has a gold badge. ;) $\endgroup$ – J. M. will be back soon Jul 18 '16 at 13:18
  • 1
    $\begingroup$ @J.M. yep, lesson learned. $\endgroup$ – Kuba Jul 18 '16 at 13:21