Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Florestan Biaux
Messenger Statistics
Commits
f2491e94
Commit
f2491e94
authored
Jul 21, 2021
by
Florestan Biaux
💬
Browse files
Import du JSON des messages
parent
faa43228
Changes
2
Hide whitespace changes
Inline
Side-by-side
get.py
View file @
f2491e94
import
os
import
re
import
string
import
json
def
get
(
name
):
def
get
name
(
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
)
main.py
View file @
f2491e94
...
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment