-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfile_manager.py
47 lines (34 loc) · 915 Bytes
/
file_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pandas as pd
class FileManager():
"""
File Manager CLass
Converts a dictionary to a pandas dataframe and saves it as a .csv file
Attributes
----------
path : str
Path to the folder name
Methods
----------
write(filename, data) : Writes the data to the file
"""
def __init__(self, path):
"""
Parameters
----------
path : str
Path to the folder name
"""
self.path = path
def write(self, filename, data):
"""
Writes the data to the file
Parameters
----------
filename : str
Name of the file to write
data : dictionary
dictionary to write
"""
filepath = self.path + filename
dataframe = pd.DataFrame.from_dict(data)
dataframe.to_csv(filepath, index=None)