The file system
- create a .txt file
-
with open("filename.txt) as
keyword -
open()
method creates a new file when it doesn't exist -
read
andwrite
methods setting a mode
"r"
(read),"w"
(write),"a"
(append)absolute file path: starts from origin
root: /relative file path: starts from working directory
one step down: ./
one step up: ../
Intro to CSV(comma-separated values)
csv library
- built-in
- csv.reader(data)
pandas library
- dataframe
- series
- get data in each column by
data.columnname
ordata["columnname"]
. Returns a series - get data in each row by first getting the column value in the row and searching its index.
data[data.columnname == item]
- turn series into list through
to_list
- turn list into dataframe through
pandas.Dataframe(list)
- turn dataframe into csv file through
dataframe.to_csv("filename.csv")
Top comments (0)