Skip to content

Commit e0512da

Browse files
committed
finished v1 of csv
1 parent 51b5cf0 commit e0512da

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

code/justin/contacts.csv

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name,phone,state,spirit animal
2+
Justin,5558675309,MS,mick jagger
3+
Jane, 1115558798, CA, turtle
4+
Mick, 8887775498, PA, woodpecker
5+
Sam, 9876543215, AR, hogger
6+
x
7+
x
8+
x
9+
x

code/justin/files.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from hashlib import new
2+
3+
4+
contacts=[]
5+
keys=[]
6+
ncontacts=[]
7+
dic={}
8+
p=1
9+
new_entry = []
10+
n = input('enter a name: ')
11+
new_entry.append(n)
12+
ph = input('enter a phone number: ')
13+
new_entry.append(ph)
14+
st = input(f'enter {n}\'s state: ')
15+
new_entry.append(st)
16+
sa = input(f'enter {n}\'s spirit animal: ')
17+
new_entry.append(sa)
18+
with open('contacts.csv', 'a') as file:
19+
for x in new_entry:
20+
file.write(f'\nx')
21+
22+
23+
# with open('contacts.csv', 'a') as file:
24+
# new_entry = str(new_entry)
25+
# contacts.csv.write(new_entry)
26+
27+
with open('contacts.csv', 'r') as file:
28+
lines = file.read().split('\n')
29+
for l in lines:
30+
contacts.append(l.split(','))
31+
for c in contacts[0]:
32+
keys.append(c)
33+
contacts.append(new_entry)
34+
while p < len(contacts):
35+
a = dic.copy()
36+
for k in keys: # k is contacts[0](headers.csv) iterated over
37+
for c in contacts[p]: # c is each contacts information iterated over
38+
x = contacts[p].index(c)
39+
contacts[p].pop(x)
40+
a[k] = c
41+
break
42+
p+=1
43+
ncontacts.append(a)
44+
45+
print(contacts)
46+
print(ncontacts)
47+

code/justin/hello.txt

Whitespace-only changes.

code/justin/tictac.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
a = ['|-|-|-|-|-|-|-|',
2+
'|-|-|-|-|-|-|-|',
3+
'|-|-|-|-|-|-|-|',
4+
'|-|-|-|-|-|-|-|',
5+
'|-|-|-|-|-|-|-|',
6+
'|-|-|-|-|-|-|-|']
7+
for x in a:
8+
print(x.strip(''))

0 commit comments

Comments
 (0)