8
$\begingroup$

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)

$\endgroup$
0

2 Answers 2

8
$\begingroup$

This is one workaround:

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

header = First[csv]

data = Rest[csv];

Dataset[
 AssociationThread[header -> #] & /@ data
]
$\endgroup$
3
  • $\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$ Commented Jul 10, 2014 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
    Commented Jul 10, 2014 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
    Commented Jul 10, 2014 at 20:39
5
$\begingroup$

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).

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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