-
Notifications
You must be signed in to change notification settings - Fork 0
/
importdata.py
73 lines (51 loc) · 1.21 KB
/
importdata.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
67
68
69
70
71
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 10 08:55:22 2023
@author: isabelbeaulieu
"""
import pandas as pd
import os
path= '/Users/isabelbeaulieu/Desktop/Data Mining'
os.chdir(path)
sentence = []
emotion = []
#training data
sentence = []
emotion = []
with open("train.txt") as f:
for line in f:
line = line.split(";")
sentence.append(line[0])
emotion.append(line[1].strip('\n'))
train = pd.DataFrame()
train['sentence'] = sentence
train['emotion'] = emotion
train
#testing data
sentence = []
emotion = []
with open("test.txt") as f:
for line in f:
line = line.split(";")
sentence.append(line[0])
emotion.append(line[1].strip('\n'))
test = pd.DataFrame()
test['sentence'] = sentence
test['emotion'] = emotion
test
#validation data
sentence = []
emotion = []
with open("val.txt") as f:
for line in f:
line = line.split(";")
sentence.append(line[0])
emotion.append(line[1].strip('\n'))
val = pd.DataFrame()
val['sentence'] = sentence
val['emotion'] = emotion
val
train.to_csv("train.csv", index = False)
test.to_csv("test.csv", index = False)
val.to_csv("val.csv", index = False)