From 660cb45e861e12727dce82b22d25aa64bcf29210 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mert=20G=C3=B6r?= Date: Thu, 24 Aug 2023 13:41:49 +0300 Subject: [PATCH] dict open example --- python-temel/dict.open.py | 8 ++++++++ python-temel/dict.open.py~ | 8 ++++++++ python-temel/test.csv | 4 ++++ 3 files changed, 20 insertions(+) create mode 100644 python-temel/dict.open.py create mode 100644 python-temel/dict.open.py~ create mode 100644 python-temel/test.csv diff --git a/python-temel/dict.open.py b/python-temel/dict.open.py new file mode 100644 index 0000000..ad6074a --- /dev/null +++ b/python-temel/dict.open.py @@ -0,0 +1,8 @@ +d = dict() +with open('test.csv', 'r') as f: + for line in f: + if line.strip() == '': + continue + l = line.split(',') + d[l[0]] = l[1].strip() + print(d) diff --git a/python-temel/dict.open.py~ b/python-temel/dict.open.py~ new file mode 100644 index 0000000..f5957b3 --- /dev/null +++ b/python-temel/dict.open.py~ @@ -0,0 +1,8 @@ +d = dict() +with open('test.txt', 'r') as f: + for line in f: + if line.strip() == '': + continue + l = line.split(',') + d[1[0]] = l[1].strip() + print(d) diff --git a/python-temel/test.csv b/python-temel/test.csv new file mode 100644 index 0000000..0f2bf42 --- /dev/null +++ b/python-temel/test.csv @@ -0,0 +1,4 @@ +Ali,123 +Veli,456 +Selami,678 +Fatma,789 \ No newline at end of file