-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_manager.py
35 lines (27 loc) · 846 Bytes
/
data_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
# Do not modify this file
def get_table_from_file(file_name):
"""
Reads csv file and returns it as a list of lists.
Lines are rows columns are separated by ";"
Args:
file_name (str): name of file to read
Returns:
list: List of lists read from a file.
"""
with open(file_name, "r") as file:
lines = file.readlines()
table = [element.replace("\n", "").split(";") for element in lines]
return table
def write_table_to_file(file_name, table):
"""
Writes list of lists into a csv file.
Args:
file_name (str): name of file to write to
table (list): list of lists to write to a file
Returns:
None
"""
with open(file_name, "w") as file:
for record in table:
row = ';'.join(record)
file.write(row + "\n")