4
$\begingroup$

I am trying to import a .csv file which has columns of strings, reals and dates. Import keeps giving me the dates as DateObject, which make it difficult to export later on. How can I disable that feature when importing?

$\endgroup$

closed as off-topic by Szabolcs, Henrik Schumacher, m_goldberg, eyorble, MarcoB Sep 13 '18 at 13:54

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

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Szabolcs, Henrik Schumacher, m_goldberg, eyorble, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    $\begingroup$ Welcome to Mathematica.SE! Could you please share the code you use to import and few lines of a .csv file in the same format as have? $\endgroup$ – Johu Sep 11 '18 at 22:21
  • $\begingroup$ Also, please tell us how you want to represent dates in Mathematica if not as DateObject $\endgroup$ – m_goldberg Sep 12 '18 at 0:17
  • $\begingroup$ Take a look at ReadList and friends. $\endgroup$ – Kuba Sep 12 '18 at 3:03
  • 1
    $\begingroup$ Please show a complete example: a sample CSV files (2-3 lines are enough), and the precise Import command you were using. I cannot reproduce what you claim and the documentation seems to state that Import does not interpret dates by default. That has to be requested explicitly through the "DateStringFormat" option. $\endgroup$ – Szabolcs Sep 12 '18 at 7:06
  • $\begingroup$ Yeah, an example CSV file would be great. $\endgroup$ – Henrik Schumacher Sep 12 '18 at 7:13
2
$\begingroup$

If data contains an array of what you have imported, then you can convert all DateObjects into strings by data /. a_DateObject :> DateString[a].

$\endgroup$

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