-
Notifications
You must be signed in to change notification settings - Fork 1
/
KTJ19.py
67 lines (26 loc) · 745 Bytes
/
KTJ19.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# coding: utf-8
# In[14]:
fileInput = "dataset.json"
fileOutput = "output.csv"
# In[20]:
inputFile = open(fileInput, 'r', encoding="utf8") #open json file
outputFile = open(fileOutput, 'w', encoding='utf8') #load csv file
# In[21]:
data = json.load(inputFile) #load json content
inputFile.close() #close the input file
# In[22]:
output = csv.writer(outputFile) #create a csv.write
# In[23]:
output.writerow(data[0].keys()) # header row
# In[24]:
for row in data:
output.writerow(row.values()) #values row
# In[25]:
import pandas as pd
data=pd.read_csv('output.csv')
# In[28]:
cat=data['category']
# In[29]:
len(set(cat))
# In[30]:
# There are 41 unique output categories in the given data set.