Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kurs_alx_pcz
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
kurs_alx_pcz
Commits
6a559262
Commit
6a559262
authored
Dec 11, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
emps_obiektowo - funkcja read_csv
parent
edf55bce
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletions
+16
-1
employees.py
dzien8/emps2_obiektowo/employees.py
+10
-1
p0_test_odczytu.py
dzien8/emps2_obiektowo/p0_test_odczytu.py
+6
-0
No files found.
dzien8/emps2_obiektowo/employees.py
View file @
6a559262
# W tym pliku mamy definicję klasy Employee - obiekt tej klasy reprezentuje jednego pracownika i zawiera jego dane.
# Mamy też funkcje odpowiedzialne za odczyt i zapis danych z/do pliku csv.
class
Employee
:
def
__init__
(
self
,
employee_id
,
first_name
,
last_name
,
job_title
,
salary
,
hire_date
,
department_name
,
address
,
postal_code
,
city
,
country
):
...
...
@@ -19,4 +20,12 @@ class Employee:
return
f
'Pracownik nr {self.employee_id}: {self.first_name} {self.last_name} ({self.job_title}), pensja {self.salary}'
def
read_csv
(
file_path
=
'emps.csv'
):
emps
=
[]
with
open
(
file_path
,
mode
=
'r'
,
encoding
=
'utf-8'
)
as
file
:
file
.
readline
()
for
line
in
file
:
t
=
line
.
strip
()
.
split
(
';'
)
emp
=
Employee
(
int
(
t
[
0
]),
t
[
1
],
t
[
2
],
t
[
3
],
int
(
t
[
4
]),
t
[
5
],
t
[
6
],
t
[
7
],
t
[
8
],
t
[
9
],
t
[
10
])
emps
.
append
(
emp
)
return
emps
dzien8/emps2_obiektowo/p0_test_odczytu.py
0 → 100644
View file @
6a559262
from
employees
import
read_csv
emps
=
read_csv
(
'emps.csv'
)
print
(
'Liczba odczytanych rekordów:'
,
len
(
emps
))
for
emp
in
emps
:
print
(
emp
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment