Python> List> Convert relative paths to absolute paths> all_filepaths = [datas_path + fp for fp in train_filepaths]

Operating environment


GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.

Learning the Deep Learning framework TensorFlow.

https://ischlag.github.io/2016/06/19/tensorflow-input-pipeline-example/

There was an example of converting a relative file path to an absolute file path for a Python list above, so I'll post it for future reference.

python_001.py



dataset_path = "/AAA/BBB/CCC/"

train_filepaths = [ "test.dat", "test.csv", "test.exe" ]

all_filepaths = [ dataset_path + fp for fp in train_filepaths ]

print(all_filepaths)

result


$ python python_001.py 
['/AAA/BBB/CCC/test.dat', '/AAA/BBB/CCC/test.csv', '/AAA/BBB/CCC/test.exe']

Recommended Posts

Python> List> Convert relative paths to absolute paths> all_filepaths = [datas_path + fp for fp in train_filepaths]
Convert absolute URLs to relative URLs in Python
Rewrite relative links in html to absolute links in python (lxml)
[Python] Convert list to Pandas [Pandas]
Useful tricks related to list and for statements in Python
Convert Excel file to text in Python for diff purposes
Convert markdown to PDF in Python
Convert list to DataFrame with python
Python> list> Convert double list to single list
[Python] How to convert a 2D list to a 1D list
Convert psd file to png in Python
python> Convert tuple to list> aList = list (pi_tuple)
Convert from Markdown to HTML in Python
Convert FBX files to ASCII <-> BINARY in Python
How to clear tuples in a list (Python)
Try to calculate RPN in Python (for beginners)
Convert exponential notation float to str in Python
Convert cubic mesh code to WKT in Python
Convert strings to character-by-character list format with python
How to remove duplicate elements in Python3 list
Tool to make mask image for ETC in Python
[For beginners] How to use say command in python!
How to convert / restore a string with [] in python
How to convert Python # type for Python super beginners: str
Convert NumPy array "ndarray" to lilt in Python [tolist ()]
Convert CIDR notation netmask to dotted decimal notation in Python
How to run python in virtual space (for MacOS)
Things to note when initializing a list in Python
[Python] How to sort dict in list and instance in list
Convert callback-style asynchronous API to async / await in Python
Convert / return class object to JSON format in Python
Convert Webpay Entity type to Dict type (recursively in Python)
[Python] How to output the list values in order
Sorted list in Python
Filter List in Python
List method argument information for classes and modules in Python
A story about how to specify a relative path in python.
Developed a library to get Kindle collection list in Python
How to define multiple variables in a python for statement
[Road to intermediate Python] Use if statement in list comprehension
How to specify Cache-Control for blob storage in Azure Storage in Python
Convenient writing method when appending to list continuously in Python
How to get the last (last) value in a list in Python
How to implement Python EXE for Windows in Docker container
How to convert Python # type for Python super beginners: int, float
Convert images passed to Jason Statham-like in Python to ASCII art