<jupyter_start><jupyter_text>Loading Data From An HTTP Server TutorialMLDB gives users full control over where and how data is persisted. MLDB handles multiple protocol for URLs (see [Files and URLs](../../../../doc/builtin/Url.md.html)). In this tutorial, we provide examples to load files via  http://  or  https:// for files accessible on a HTTP server on the public internet or a private intranet.For an example using the  file://  for a file inside an MLDB container, see the [Loading Data Tutorial](../../../../ipy/notebooks/_tutorials/_latest/Loading%20Data%20Tutorial.ipynb) for an example. MLDB also supports loading files from Amazon S3 and SFTP servers transparently. See the documentation for [Files and URLs](../../../../doc/builtin/Url.md.html) for more details. The notebook cells below use `pymldb`'s `Connection` class to make [REST API](../../../../doc/builtin/WorkingWithRest.md.html) calls. You can check out the [Using `pymldb` Tutorial](../../../../doc/nblink.html_tutorials/Using pymldb Tutorial) for more details.<jupyter_code>from pymldb import Connection
mldb = Connection()<jupyter_output><empty_output><jupyter_text>Loading data with http:// or https://MLDB makes it very easy to load data from a public web server, since a file location can be specified using a remote URI. To illustrate this, we have chosen to load a file from the [Facebook Social Circles](http://snap.stanford.edu/data/egonets-Facebook.html) dataset, hosted by the [Stanford Network Analysis Project (SNAP)](http://snap.stanford.edu/index.html), who provide many public datasets. We will simply import the file `http://snap.stanford.edu/data/facebook_combined.txt.gz` using the [`import.text` procedure](../../../../doc/builtin/procedures/importtextprocedure.md.html). Notice that not only is the file hosted on a remote server, but it is also compressed. MLDB will decompress it seamlessly as it's being downloaded.<jupyter_code>dataUrl = "http://snap.stanford.edu/data/facebook_combined.txt.gz"

print mldb.put("/v1/procedures/import_data", {
    "type": "import.text",
    "params": {
        "dataFileUrl": dataUrl,
        "headers": ["node", "edge"],
        "delimiter": " ", 
        "quoteChar": "",
        "outputDataset": "import_URL1",
        "runOnCreation": True
    }
})<jupyter_output><Response [201]><jupyter_text>We can now take a look:<jupyter_code>mldb.query("SELECT * FROM import_URL1 LIMIT 5")<jupyter_output><empty_output><jupyter_text>Accessing a specific file inside an archiveIf the targeted file is inside an archive (`.tar` or `.zip`), we can specify the specific file we want to extract, as seen in the example below. Here, we load the `3980.circles` file within the `facebook` folder:<jupyter_code>dataUrl = "http://snap.stanford.edu/data/facebook.tar.gz"

print mldb.put("/v1/procedures/import_data", {
    "type": "import.text",
    "params": {
        "dataFileUrl": "archive+" + dataUrl + "#facebook/3980.circles",
        "headers": ["circles"],
        "delimiter": " ", 
        "quoteChar": "",
        "outputDataset": "import_URL2",
        "runOnCreation": True
    }
})<jupyter_output><Response [201]><jupyter_text>Let's query our dataset to see what the data looks like:<jupyter_code>mldb.query("SELECT * from import_URL2 LIMIT 5")<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13282904689863842, 'fraction_numerical': 0.008169440242057489, 'mean_word_length': 4.070552147239264, 'pattern_counts': {'":': 16, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '259761', 'license': 'Apache-2.0', 'n_tokens_mistral': 1019, 'n_tokens_neox': 994, 'n_words': 327, 'path': 'container_files/tutorials/Loading Data From An HTTP Server Tutorial.ipynb', 'repo_name': 'kstepanmpmg/mldb', 'size': '3305'}