1
$\begingroup$

In attempting to scrape data from a Wikipedia table for conversion into a Dataset, I discovered that the simple program posted in another thread works rather well.

 text2 = Import[
 "https://en.wikipedia.org/wiki/List_of_solar_thermal_power_\
  stations", "Data"];
  table2 = Cases[text2, {_, _, _, _, _,   _, _}, \[Infinity]]
  Dataset[table2[[2 ;; 74]]][All, 
  AssociationThread[col, Range[Length[col]]]]

However, on closer inspection I note that the data [XML?] for the table appears not to be well formed and consequently some rows in the table are actually missing (ignore the fact that I intentionally dropped the first and a few at the end that were actually text and not part of the scraped table, hence the [[2;;74]]).

Its seems that the easiest way to deal with this complicated table, given that attempts to import as an XMLObject were stymied by the complexity of the table, which appears to have numerous XMLElements of differing size (invalid XML?), might be to simply store the Dataset as an association, edit that for the few missing records and then translate the list of associations back to a new revised dataset.

Is there a simple function that permits one to retrieve the associations (key, value) pairs from the dataset so that they could be edited and the Dataset rebuilt?

Normally one doesn't need to do this since one starts with an association to get the Dataset as is evident in numerous examples in the documentation. However, I am confused as to how to retrieve/write out the intrinsic list of associations so that the corrections can be readily made to the intrinsic association list so that the revised list of associations could then be used to create a new corrected dataset.

Although one could seemingly merge two datasets with the same underlying structure to add a few missing records, this does not seem to resolve a few problem incomplete records that still have found their way into the table during the translation. Consequently,it would seem gaining access and storing the association list, editing it, and then rebuilding the Dataset would be the easiest way to deal with problematic tables of this kind.

$\endgroup$

closed as off-topic by MarcoB, ubpdqn, corey979, m_goldberg, Kuba Feb 10 '17 at 12:49

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

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – MarcoB, ubpdqn, corey979, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    $\begingroup$ Without checking details, is Normal the answer? $\endgroup$ – Kuba Feb 9 '17 at 11:28
  • 1
    $\begingroup$ You may find this answer of interest. $\endgroup$ – m_goldberg Feb 9 '17 at 11:36
  • $\begingroup$ This is EXACTLY what I was seeking. I had glanced at your earlier post and at the Normal documentation but it had not sunk in. Thank you. I see in the Tour that I can mark this question as now answered, but don't see exactly where on this page I should do so. $\endgroup$ – Stuart Poss Feb 9 '17 at 17:33
  • $\begingroup$ Possible duplicate of Change Values in Dataset under Condition $\endgroup$ – Kuba Feb 10 '17 at 12:49

Browse other questions tagged or ask your own question.