├── requirements.txt ├── README.md ├── main.py ├── .github └── workflows │ └── cron.yml └── data.csv /requirements.txt: -------------------------------------------------------------------------------- 1 | lxml 2 | pandas 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Space Weather (magnetometer readings, 7-day) 2 | Testing Github Actions with pandas and Wikipedia. 3 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | # Utility function to scrape space weather data. 4 | def scrape_space_weather(url): 5 | df = pd.read_json(url) 6 | return re.sub(r"\[?\s*(\d+)(?=(?:, \d+)|\])(?=[^\[]*\]).", "", df.to_csv(index=False)) 7 | 8 | 9 | if __name__ == '__main__': 10 | with open('data.csv', 'w+') as f: 11 | f.write(scrape_space_weather('https://services.swpc.noaa.gov/products/solar-wind/mag-7-day.json')) 12 | -------------------------------------------------------------------------------- /.github/workflows/cron.yml: -------------------------------------------------------------------------------- 1 | name: scrape-mineral-hardnesses 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | schedule: 8 | - cron: "0 */1 * * *" 9 | 10 | jobs: 11 | build-and-deploy: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Get working version 15 | uses: actions/checkout@master 16 | with: 17 | fetch-depth: 1 18 | - name: 🐍 Python setup 19 | uses: actions/setup-python@v2 20 | with: 21 | python-version: '3.8' 22 | - name: Install Python dependencies 23 | run: pip install -r requirements.txt 24 | - name: Update the hardnesses dataset 25 | run: python main.py 26 | - name: Commit and push if the data has changed 27 | run: | 28 | git config user.name "${GITHUB_ACTOR}" 29 | git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" 30 | git add -A 31 | timestamp=$(date -u) 32 | git commit -m "Latest data: ${timestamp}" || exit 0 33 | git push -------------------------------------------------------------------------------- /data.csv: -------------------------------------------------------------------------------- 1 | number,symbol,name,Mohs hardness,Vickers hardness(MPa),Brinell hardness(MPa),Brinell hardness(MPa)[note 2 | 3,Li,lithium,0.6,,5, 3 | 4,Be,beryllium,5.5,1670,590–1320, 4 | 5,B,boron,9.3-9.5 ,4900-5800 ,, 5 | 6,C,carbon (graphite),0.5,,, 6 | 6,C,carbon (diamond),10.0,,, 7 | 11,Na,sodium,0.5,,0.69, 8 | 12,Mg,magnesium,2.5,,260,44 (cast) 9 | 13,Al,aluminium,2.75,160–350,160–550,184 10 | 14,Si,silicon,6.5,,, 11 | 16,S,sulfur,2.0,,, 12 | 19,K,potassium,0.4,,0.363, 13 | 20,Ca,calcium,1.75,,170,416 14 | 21,Sc,scandium,,,736–1200, 15 | 22,Ti,titanium,6.0,830–3420,716–2770,1028 16 | 23,V,vanadium,7.0,628–640,600–628,742 17 | 24,Cr,chromium,8.5,1060,687-6500,688 18 | 25,Mn,manganese,6.0,,196, 19 | 26,Fe,iron,4.0,608,200-1180, 20 | 27,Co,cobalt,5.0,1043,470–3000,1291 21 | 28,Ni,nickel,4.0,638,667–1600,900–1200 22 | 29,Cu,copper,3.0,343–369,235–878,520 23 | 30,Zn,zinc,2.5,,327–412,480–520 24 | 31,Ga,gallium,1.5,,56.8–68.7, 25 | 32,Ge,germanium,6.0,,, 26 | 33,As,arsenic,3.5,,1440, 27 | 34,Se,selenium,2.0,,736, 28 | 37,Rb,rubidium,0.3,,0.216, 29 | 38,Sr,strontium,1.5,,, 30 | 39,Y,yttrium,,,200–589, 31 | 40,Zr,zirconium,5.0,820–1800,638–1880,333 32 | 41,Nb,niobium,6.0,870–1320,735–2450,735 33 | 42,Mo,molybdenum,5.5,1400–2740,1370–2500,1340 (cast) 34 | 44,Ru,ruthenium,6.5,,2160,1795 35 | 45,Rh,rhodium,6.0,1100–8000,980–1350,540 36 | 46,Pd,palladium,4.75,400–600,320–610,310 37 | 47,Ag,silver,2.5,250,245–250,206 38 | 48,Cd,cadmium,2.0,,203–220,196 39 | 49,In,indium,1.2,,8.83-10,9.8 40 | 50,Sn,tin,1.5,,51–75,292–441 (cast) 41 | 51,Sb,antimony,3.0,,294–384, 42 | 52,Te,tellurium,2.25,,180–270, 43 | 55,Cs,caesium,0.2,,0.147, 44 | 56,Ba,barium,1.25,,, 45 | 57,La,lanthanum,2.5,360–1750,350–400, 46 | 58,Ce,cerium,2.5,210–470,186–412, 47 | 59,Pr,praseodymium,,250–746,250–638, 48 | 60,Nd,neodymium,,343–746,265–700, 49 | 61,Pm,promethium,,617.8,, 50 | 62,Sm,samarium,,412–441,441–600, 51 | 63,Eu,europium,,167–200,, 52 | 64,Gd,gadolinium,,510–950,, 53 | 65,Tb,terbium,,450–863,677–1200, 54 | 66,Dy,dysprosium,,412–550,500–1050, 55 | 67,Ho,holmium,,412–600,500–1250, 56 | 68,Er,erbium,,432–700,600–1070, 57 | 69,Tm,thulium,,470–650,471–900, 58 | 70,Yb,ytterbium,,206–250,343–441, 59 | 71,Lu,lutetium,,755–1160,893–1300, 60 | 72,Hf,hafnium,5.5,1520–2060,1450–2100, 61 | 73,Ta,tantalum,6.5,873–1200,441-3430,441–1224 62 | 74,W,tungsten,7.5,3430–4600,2000–4000,1960–2450 63 | 75,Re,rhenium,7.0,1350-7850,1320–2500, 64 | 76,Os,osmium,7.0,,3920–4000,3487 65 | 77,Ir,iridium,6.5,1760–2200,1670,2120 66 | 78,Pt,platinum,3.5,400–549,310–500,299 67 | 79,Au,gold,2.5,188–216,188–245,189 68 | 80,Hg,mercury,1.5,,, 69 | 81,Tl,thallium,1.2,,26.5–44.7, 70 | 82,Pb,lead,1.5,,38–50,37.5–41.8 (cast) 71 | 83,Bi,bismuth,2.25,,70–94.2,70 72 | 90,Th,thorium,3.0,294–687,390–1500, 73 | 92,U,uranium,6.0,1960–2500,2350–3850, 74 | --------------------------------------------------------------------------------