NumPy Input and Output: DataSource() function
numpy.DataSource() function
DataSources can be local files or remote files/URLs. The files may also be compressed or uncompressed.
Syntax:
class numpy.DataSource(destpath='.')
Version: 1.15.0
Parameter:
Name | Description | Required / Optional |
---|---|---|
destpath | Path to the directory where the source file gets downloaded to for use. If destpath is None, a temporary directory will be created. The default path is the current directory. str or None |
Optional |
Notes:
URLs require a scheme string (http://) to be used, without it they will fail:
>>> repos = DataSource() >>> repos.exists('www.google.com/index.html') False >>> repos.exists('http://www.google.com/index.html') True
Temporary directories are deleted when the DataSource is deleted.
NumPy.DataSource() method Example:
>>> import numpy as np
>>> ds = np.DataSource('/home/guido')
>>> urlname = 'http://www.google.com/index.html'
>>> gfile = ds.open('http://www.google.com/index.html') # remote file
>>> ds.abspath(urlname)
Output:
'C:\\home\\guido\\www.google.com\\index.html'
Python - NumPy Code Editor:
Previous: base_repr() function
Next: lib.format() function
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook