Commit f2491e94 authored by Florestan Biaux's avatar Florestan Biaux 💬
Browse files

Import du JSON des messages

parent faa43228
import os
import re
import string
import json
def get(name):
def getname(name):
# remove whitspaces
conv = name.replace(" ", "")
# lowercase
conv = conv.lower()
# regex _*
conv = conv + "_.*"
# conv = "^'" + conv + "_.*'$"
# return final conv name
return conv
def getfile(name):
originpath = os.getcwd()
path = os.getcwd() + "/messages/inbox/"
os.chdir(path)
oslist = os.listdir()
r = re.compile(name)
conv = list(filter(r.match, oslist))
conv = conv.__getitem__(0)
os.chdir(path + "/" + conv)
with open("message_1.json") as messages:
data = json.load(messages)
data_str = json.dumps(data)
print(data_str)
......@@ -6,5 +6,5 @@ if __name__ == "__main__":
# demander le nom de la conv à analyser
name = str(input("Quel est le nom de la conversation à analyser ?"))
# give regex of conversation name
conv = get.get(name)
print(conv)
\ No newline at end of file
conv = get.getname(name)
get.getfile(conv)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment