Skip to content

Instantly share code, notes, and snippets.

@vlad-bezden
Created March 17, 2019 14:47
Show Gist options
  • Save vlad-bezden/44ed5eefdeac07c0df3f3f680cedec9f to your computer and use it in GitHub Desktop.
Save vlad-bezden/44ed5eefdeac07c0df3f3f680cedec9f to your computer and use it in GitHub Desktop.
Different ways to load data from the file
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