🪟 Windows TippsMicrosoft to Hold Surface and Windows Event on October 7(16.09.2026 um 18:25 Uhr)
🪟 Windows TippsNissan bringt seinen Verkaufsschlager Kicks nach Europa(16.09.2026 um 16:34 Uhr)
🪟 Windows ServerBrowser: Firefox 156 bekommt Werbeeinblendungen - Golem.de(16.09.2026 um 17:14 Uhr)
🪟 Windows TippsMicrosoft to Hold Surface and Windows Event on October 7(16.09.2026 um 18:25 Uhr)
🪟 Windows TippsNissan bringt seinen Verkaufsschlager Kicks nach Europa(16.09.2026 um 16:34 Uhr)
🪟 Windows ServerBrowser: Firefox 156 bekommt Werbeeinblendungen - Golem.de(16.09.2026 um 17:14 Uhr)

🔧 Programmierung 🕛 vor 3 Jahren 2 Min Lesezeit
0

Fetching and Loading Data from Github

↗ Quelle (dev.to)
🗣️ Stimme:

It's usually preferable to write a function that downloads and decompresses data from github (or online data) rather than doing it manually.



This is especially true if the data changes frequently: you can write a small script that uses the function to retrieve the most recent data (of you can set up a scheduled job to do that automatically at regular intervals). Automating the data retrieval process is also useful if you need to install the dataset on multiple machines.



Here is the fuction to fetch and load data:




CODE
# ----- Libraries ---------
from pathlib import Path

import pandas as pd
import tarfile
import urllib.request
# --------------------------

# Function to fetch and load data --->
def function_name():
zipped_path = Path("datasets/files.tgz")

if not zipped_path.is_file():
Path("datasets").mkdir(parents=True, exist_ok=True)
url = "https://github.com/****/Datasets/raw/main/files.tgz"
urllib.request.urlretrieve(url, zipped_path)

with tarfile.open(zipped_path) as file_name:
file_name.extractall(path = "datasets")

return pd.read_csv(Path("datasets/files/file.csv"))

data_file = function_name()






When function_name()is called, it will look for the dataset file in datasets/files.tgz. If it does not find it, it will create a directory datasets inside your working directory; then it will download the files.tgz from the site https://github.com/****/Datasets/raw/main/files.tgz. This files.tgz contains the file file.csv.



The function with then lod the CSV file into a Pandas DataFrame object containing all the data, and return it.



You can check your data by:




CODE
print(data_file[:10])
# Or
print(housing.head())






To display the top 10 rows ( or 5 top rows) of your data.

Vollständiger Original-Artikel
Den kompletten Beitrag mit allen Details direkt auf dev.to lesen.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Microsoft to Hold Surface and Windows Event on October 7
1 Quelle
Thrustmaster's new flight stick is a heavy and authentic A-10C HOTAS replica for PC simulator fans who crave digital dogfights
1 Quelle
Nissan bringt seinen Verkaufsschlager Kicks nach Europa
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Fetching and Loading Data from Github

Thematisch verwandte Begriffe: Fetching, Loading, Data, from · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...