How to show columns in specific order

This is my Scraper https://morph.io/roshin8/HideMyAss_ProxyList_Scraper
I want to show the columns in the order
IP Address > Port > Country > Anon

How do I do this?
Thanks

Hey @roshin8 :wave:

There’s not much you can do with the data preview on the morph.io page but you can download all the data as a CSV and sort and reorder to your heart’s content :heartbeat:

If you wanna define the columns in that order (which I’m suspecting is what you actually want) place the data in an OrderedDict instead of a dict literal on line 46 of your scraper.py. You’re gonna have to clear the database on morph.io before the changes can take effect.

1 Like

I tried that. Didn’t seem to work

Thanks for the reply :slight_smile:

Well, placing a dict inside an OrderedDict is a no-op; the items within the dict will have lost their order prior to calling OrderedDict. You need to follow the example in the doc, i.e. on line 47:

-       data = OrderedDict({"IP_address": ip_address, "Port": port,  "Last_Update": last_update, "Anon": anon, "Type": connection_type,  "Country": country})
+       data = OrderedDict([("IP_address", ip_address), ("Port", port), ("Last_Update", last_update), ("Anon", anon), ("Type", connection_type), ("Country", country)])

When you export via the REST api it uses a SQL select statement. Could you just name the columns in the order you want rather than “SELECT *” ?

1 Like