SemanticImport misinterprets rows with trailing blanks. Note the commas in the 2nd column:

SemanticImport["https://docs.google.com/spreadsheet/pub?key=0Ati-pfGwn22sdGt1T3E4S3NFYWxmQXY2ZUJ0MmhXd2c&output=csv", Delimiters -> ",", HeaderLines -> 1]

enter image description here

Import[...,Delimiters->","]//Dataset doesn't recognize the header line identifiers as keys.

(Note Google has deprecated csv web pub of gsheets)


This is one workaround:

csv = Import["https://docs.google.com/spreadsheet/pub?key=0Ati-pfGwn22sdGt1T3E4S3NFYWxmQXY2ZUJ0MmhXd2c&output=csv", "CSV"];

header = First[csv]

data = Rest[csv];

 AssociationThread[header -> #] & /@ data
  • $\begingroup$ That's the solution I've been using to build key-value structures before Dataset, except as a list of Rules, hence only Thread (Association@Thread = AssociationThread). But I meant a set of options for SemanticImport? $\endgroup$ Jul 10 '14 at 20:22
  • $\begingroup$ @alancalvitti Sorry, I didn't re-read your question, and I remembered that you asked "Alternatively how to cast to Dataset from good ol' Import?" $\endgroup$
    – Szabolcs
    Jul 10 '14 at 20:24
  • $\begingroup$ @alancalvitti Here's a solution that seems nicer than AssociationThread: community.wolfram.com/groups/-/m/t/290815?p_p_auth=u7fX6KQc (still not an answer to your SemanticImport question, just an improvement on this). $\endgroup$
    – Szabolcs
    Jul 10 '14 at 20:39

This is a good test set. I'm feeding this to the primary developer on SemanticImport, hopefully we can fix this for 10.0.1 (we've already improved SemanticImport a lot since the release branch).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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