Skip to content

Commit 0d97375

Browse files
author
Harshit
committed
Adding updated files
0 parents  commit 0d97375

13 files changed

+139853
-0
lines changed

DNR_Camping_Parks_Reservation_Data_2016.csv

Lines changed: 34942 additions & 0 deletions
Large diffs are not rendered by default.

file1.csv

Lines changed: 34942 additions & 0 deletions
Large diffs are not rendered by default.

file1.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import csv
2+
3+
# create new file
4+
with open('file1.csv' , 'wb') as output:
5+
6+
# open required csv
7+
with open('DNR_Camping_Parks_Reservation_Data_2016.csv') as csv_file:
8+
output_data = csv.writer(output, delimiter =',')
9+
data = csv.reader(csv_file, delimiter=',')
10+
for row in data:
11+
output_data.writerow(row)
12+
print("Writing complete")
13+

file2.csv

Lines changed: 34942 additions & 0 deletions
Large diffs are not rendered by default.

file2.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import csv
2+
3+
# open required csv and read it as a text string
4+
with open('file1.csv', 'r') as input:
5+
csv_reader = csv.DictReader(input)
6+
7+
# open new file to save changes
8+
with open('file2.csv', 'wb') as out_file:
9+
fieldnames = ['ParkName', 'State', 'partySize', 'RateType', 'BookingType', 'Equipment']
10+
output_data = csv.DictWriter(out_file, fieldnames=fieldnames, delimiter =',')
11+
12+
output_data.writeheader()
13+
14+
#removing not required columns
15+
for line in csv_reader:
16+
del line['Country']
17+
del line['Adult']
18+
del line['Child']
19+
del line['BookingStartDate']
20+
del line['BookingEnddate']
21+
del line['Night']
22+
del line['Permits']
23+
output_data.writerow(line)
24+
25+
print("Writing complete")
26+

file3.csv

Lines changed: 34942 additions & 0 deletions
Large diffs are not rendered by default.

file3.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import re
2+
3+
# open required csv and read it as a text string
4+
with open('file2.csv', 'r') as f:
5+
my_csv_text = f.read()
6+
7+
# replace 'Less than' with LT
8+
find_str = 'Less than'
9+
replace_str = 'LT'
10+
11+
# substitute
12+
new_csv_str_lt = re.sub(find_str, replace_str, my_csv_text)
13+
14+
# replace 'Single Tent' with ST
15+
find_sstr = 'Single Tent'
16+
replace_sstr = 'ST'
17+
18+
new_csv_str_st = re.sub(find_sstr, replace_sstr, new_csv_str_lt)
19+
20+
# open new file and save changes
21+
new_csv_path = 'file3.csv' # or whatever path and name you want
22+
with open(new_csv_path, 'w') as f:
23+
f.write(new_csv_str_st)
24+
25+
print("Writing Complete")

file4.csv

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ParkName,partySize,RateType,BookingType,Equipment
2+
Dollar Lake,11,Full,CampsitePermit,ST
3+
Amherst Shore,6,Full,CampsitePermit,LT 40ft
4+
Caribou Munroes,9,Full,CampsitePermit,Tents
5+
Salsman,6,Full,CampsitePermit,Tents
6+
Five Islands,7,Full,CampsitePermit,ST
7+
Graves Island,35,Full,CampsitePermit,Tents
8+
Rissers Beach,8,Full,CampsitePermit,Tents
9+
Laurie,8,Full,CampsitePermit,LT 20ft
10+
Smileys,6,Full,CampsitePermit,LT 20ft
11+
Blomidon,10,Full,CampsitePermit,Tents
12+
Ellenwood Lake,12,Full,CampsitePermit,LT 30ft
13+
Thomas Raddall,8,Full,CampsitePermit,ST
14+
Mira River,9,Full,CampsitePermit,ST
15+
Whycocomagh,6,Full,CampsitePermit,LT 20ft
16+
Porters Lake,7,Full,CampsitePermit,ST
17+
Battery,9,Full,CampsitePermit,Tents
18+
The Islands,6,Full,CampsitePermit,LT 30ft
19+
Valleyview,11,Full,CampsitePermit,ST
20+
Cape Chignecto,14,Full,BackcountryPermit,ST
21+
Boylston,6,Full,CampsitePermit,Tents

graph images/NeghbourByEquipment.png

95.2 KB
Loading

graph images/NeghbourByRate.png

72.9 KB
Loading

0 commit comments

Comments
 (0)