Skip to content

Commit 8596d2d

Browse files
done
1 parent 2016706 commit 8596d2d

File tree

4 files changed

+22
-139
lines changed

4 files changed

+22
-139
lines changed

CSV_files/README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
- pandas Library: The pandas library is one of the open-source Python libraries that provide high-performance, convenient data structures and data analysis tools and techniques for Python programming.
77

88
* **Read using csv.DictReader() class:** the CSV file is first opened using the open() method then it is read by using the DictReader class of csv module which works like a regular reader but maps the information in the CSV file into a dictionary. The very first line of the file consists of dictionary keys.
9+
* **Read using pandas module** : you can read cvs file using pandas ,using read_csv method , you can also determine if you want to read the head or the tail or read specific piece of data .
10+
911

1012
* There are various classes provide by csv module for writting to csv:
1113
- using csv.writer class
@@ -15,4 +17,17 @@
1517

1618

1719
* **Write using pandas module**:You can save your Pandas DataFrame as a CSV file with .to_csv(data)
18-
20+
21+
22+
23+
24+
25+
# Steps :
26+
27+
1- clone the repo
28+
29+
2- poetry install
30+
31+
3- poetry shell
32+
33+
4- run the wanted file

CSV_files/poetry.lock

Lines changed: 0 additions & 120 deletions
This file was deleted.

CSV_files/pyproject.toml

Lines changed: 0 additions & 15 deletions
This file was deleted.

CSV_files/read_csv.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import csv
2+
import pandas as pd
23

34
def read_using_DictReader():
45
# opening the CSV file
@@ -10,8 +11,10 @@ def read_using_DictReader():
1011
for lines in csvFile:
1112
return lines
1213

13-
14-
14+
def read_by_pandas():
15+
data=pd.read_csv('CSV_files/assets/addresses.csv')
16+
return data.head()
1517

1618
if __name__=="__main__":
17-
print(read_using_DictReader())
19+
print(read_using_DictReader())
20+
print(read_by_pandas())

0 commit comments

Comments
 (0)