Created
March 17, 2019 14:47
-
-
Save vlad-bezden/44ed5eefdeac07c0df3f3f680cedec9f to your computer and use it in GitHub Desktop.
Different ways to load data from the file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file = "some_file_path.csv" | |
# Option #1 using readlines(). It will create list of lines | |
with open(file, "r") as reader: | |
lines = reader.readlines() | |
# Option #2. Read line by line and add to the list | |
with open(file, "r") as reader: | |
lines = [] | |
for line in reader: | |
lines.append(line) | |
# Option #3 load data to the tuple | |
lines = tuple(open(file, "r")) | |
# option #4 load to the list | |
lines = list(open(file, "r")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment