Group Abstract Group Abstract

Message Boards Message Boards

0
|
64 Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Wolfram 14.2 Import CSV generating Missing[NotAvailable]

Posted 2 days ago

I have a number of CSV files with values of "" interspersed with data values. Under previous Wolfram versions, these imported as "" (which is how they appear in the file). However under Mathematica 14.2 (I just upgraded), I now have many many Missing[NotAvailable] instead of the "". The data is not missing.

I searched the forum under CSV and Missing[NotAvailable] and was surprised not to find something.

Command:

Import[ fileName.csv]

and similar result

Import[ filename.csv, "CSV"]  

Obviously, no problem with I say Import[ fileName.csv, "Text"] as the problem is in the Import process.

I explored setting a MissingValuePattern, EmptyField, and other ideas, but nothing has worked yet.

Any recommendations (other than import text and do it myself)?

POSTED BY: Bloor Redding
3 Replies

This behavior is documented and the workaround is provided in the Possible Issues section of https://reference.wolfram.com/language/ref/format/CSV.html. You should use MissingValuePattern -> None.

In[1]:= csv = ExportString[{{5.7, ""}, {-1.2, 7.8}}, "CSV"]

Out[1]= "5.7,
-1.2,7.8
"
In[2]:= ImportString[csv, "CSV"]

Out[2]= {{5.7, Missing["NotAvailable"]}, {-1.2, 7.8}}

In[3]:= ImportString[csv, "CSV", MissingValuePattern -> None]

Out[3]= {{5.7, ""}, {-1.2, "7.8"}}
POSTED BY: Piotr Wendykier

Thank You! That is exactly what I was looking for. It fixed the problem.

I figured there was an option. I had tried MissingValuePattern -> "" without success. I had not considered None. The documentation seemed to me to suggest a need for a pattern or test.

Thank you for pointing out the note in Possible Issues. I didn't check there this time, although I have looked at Possible Issues in the past. I've never seen as long a list of issues. I'm not sure I would have immediately recognized the connection between the ImportString example and the Import, but I agree now it's a good example. I see a few other notes for 14.2, so I'll keep them in mind as I port the code over. Thanks again!

POSTED BY: Bloor Redding

Yes, it seems that the behaviour has changed with version 14.2. Here is a possible workaround:

Export["out.csv", {{5.7, ""}, {-1.2, 7.8}}]
Import["out.csv"] /. Missing["NotAvailable"] -> ""
POSTED BY: Gianluca Gorni
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard