Time conversion
Closed this issue · 4 comments
sattarbadangiz commented
rwa_read function did not work for iranian (persian) time format.
JBGruber commented
Can you post a couple of lines from your chat file? I can take a look and maybe fix it.
sattarbadangiz commented
در تاریخ جمعه ۴ فوریهٔ ۲۰۲۲، ۱۹:۴۴ Johannes Gruber <
***@***.***> نوشت:
Can you post a couple of lines from your chat file? I can take a look and
maybe fix it.
—
Reply to this email directly, view it on GitHub
<#28 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASR6KGESLSQPKREA344ZYGTUZP3PTANCNFSM5NSFJKNQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
۲۰۲۱/۵/۳۰، ۱۸:۴۴ - پیامها و تماسها سرتاسر رمزگذاری شدهاند. هیچ شخصی خارج از گفتگو حتی خود واتساپ هم نمیتواند آنها را بخواند یا بشنود. برای کسب اطلاعات بیشتر، اینجا را بزنید.
۲۰۲۱/۵/۳۰، ۱۸:۴۴ - Sattar-b: سلام،خسته نباشید
۲۰۲۱/۵/۳۰، ۱۸:۴۴ - Sattar-b: در مورد اطلاعیه شطرنجتون،میخواستم بدونم شرایطش چجوریه
۲۰۲۱/۵/۳۰، ۱۸:۴۵ - شطرنج: سلام مچکرم
۲۰۲۱/۵/۳۰، ۱۸:۴۵ - شطرنج: در خدمتم
۲۰۲۱/۵/۳۰، ۱۸:۴۵ - Sattar-b: مسابقاته یا آموزش شطرنج؟اگه آموزش میشه شرایطش و بگید
۲۰۲۱/۵/۳۰، ۱۸:۴۶ - شطرنج: هم مسابقات داریم هم اموزش
۲۰۲۱/۵/۳۰، ۱۸:۴۶ - شطرنج: اموزش یه صورت عمومی و خصوصی و نیمه خصوصی
۲۰۲۱/۵/۳۰، ۱۸:۴۷ - شطرنج: کلاس نیمه خصوصی از شنبه هفته اینده برگزار میشه
۲۰۲۱/۵/۳۰، ۱۸:۴۷ - شطرنج: میتونید شرکت کنید
۲۰۲۱/۵/۳۰، ۱۸:۴۷ - Sattar-b: کلاس ها بصورت انلاینه؟هزینهش چقدره؟
۲۰۲۱/۵/۳۰، ۱۸:۴۸ - شطرنج: فعلا کلاسا به صورت حضوری برگزار میشه
۲۰۲۱/۵/۳۰، ۱۸:۴۸ - Sattar-b: مسابقاتم حضوریه؟
۲۰۲۱/۵/۳۰، ۱۸:۴۹ - شطرنج: بله دیرمز مسابقات داشتیم
۲۰۲۱/۵/۳۰، ۱۸:۴۹ - شطرنج: <رسانه حذف شد>
۲۰۲۱/۵/۳۰، ۱۸:۵۰ - شطرنج: <رسانه حذف شد>
۲۰۲۱/۵/۳۰، ۱۸:۵۱ - Sattar-b: محل برگزاری مسابقات کجاست؟هزینه هم داره یا نه؟
۲۰۲۱/۵/۳۰، ۱۸:۵۲ - شطرنج: هفده شهریور
۲۰۲۱/۵/۳۰، ۱۸:۵۲ - شطرنج: بله هزینه داره
۲۰۲۱/۵/۳۰، ۱۸:۵۲ - شطرنج: یه مسابقات هفتگی هم داریم باشگاه شطرنج
۲۰۲۱/۵/۳۰، ۱۸:۵۲ - شطرنج: نبش دانشگاه 3
۲۰۲۱/۵/۳۰، ۱۸:۵۵ - Sattar-b: هزینهش چقدره و چه ساعتی برگزار میشه ؟
۲۰۲۱/۵/۳۰، ۱۸:۵۵ - شطرنج: روز های جمعه ساعت 5
۲۰۲۱/۵/۳۰، ۱۸:۵۵ - شطرنج: هزینه 30
۲۰۲۱/۵/۳۰، ۱۸:۵۸ - Sattar-b: ممنونم
۲۰۲۱/۵/۳۰، ۱۸:۵۹ - شطرنج: خواهش میکنم
JBGruber commented
I found an easy fix for this problem by converting the Persian numbers before running rwa_read
. I wrapped some code I found on SO in a function and convert the numbers on the fly. Could you confirm that this does what you expect? I put your text into a txt file called rwatest.txt and use this code:
convert_numbers <- function(x) {
chartr(
# persian
"\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9",
# arabic
"\U0030\U0031\U0032\U0033\U0034\U0035\U0036\U0037\U0038\U0039\U0030\U0031\U0032\U0033\U0034\U0035\U0036\U0037\U0038\U0039",
x)
}
df <- rwhatsapp::rwa_read(x = convert_numbers(readLines("rwatest.txt")))
df
#> # A tibble: 26 × 6
#> time author text source emoji emoji_name
#> <dttm> <fct> <chr> <chr> <lis> <list>
#> 1 2021-05-30 18:44:57 <NA> پیامها و تماسها سرتاسر… text i… <NUL… <NULL>
#> 2 2021-05-30 18:44:57 Sattar-b سلام،خسته نباشید text i… <NUL… <NULL>
#> 3 2021-05-30 18:44:57 Sattar-b در مورد اطلاعیه شطرنجت… text i… <NUL… <NULL>
#> 4 2021-05-30 18:45:57 شطرنج سلام مچکرم text i… <NUL… <NULL>
#> 5 2021-05-30 18:45:57 شطرنج در خدمتم text i… <NUL… <NULL>
#> 6 2021-05-30 18:45:57 Sattar-b مسابقاته یا آموزش شطرن… text i… <NUL… <NULL>
#> 7 2021-05-30 18:46:57 شطرنج هم مسابقات داریم هم ام… text i… <NUL… <NULL>
#> 8 2021-05-30 18:46:57 شطرنج اموزش یه صورت عمومی و … text i… <NUL… <NULL>
#> 9 2021-05-30 18:47:57 شطرنج کلاس نیمه خصوصی از شنب… text i… <NUL… <NULL>
#> 10 2021-05-30 18:47:57 شطرنج میتونید شرکت کنید text i… <NUL… <NULL>
#> # … with 16 more rows
Created on 2022-02-05 by the reprex package (v2.0.1)
sattarbadangiz commented
Yes i do,thanks
در تاریخ شنبه ۵ فوریهٔ ۲۰۲۲، ۲۳:۲۳ Johannes Gruber <
***@***.***> نوشت:
… I found an easy fix for this problem by converting the Persian numbers
before running rwa_read. I wrapped some code I found on SO in a function
and convert the numbers on the fly. Could you confirm that this does what
you expect? I put your text into a txt file called rwatest.txt and use this
code:
convert_numbers <- function(x) {
chartr(
# persian
"\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669\u06F0\u06F1\u06F2\u06F3\u06F4\u06F5\u06F6\u06F7\u06F8\u06F9",
# arabic
"\U0030\U0031\U0032\U0033\U0034\U0035\U0036\U0037\U0038\U0039\U0030\U0031\U0032\U0033\U0034\U0035\U0036\U0037\U0038\U0039",
x)
}
df <- rwhatsapp::rwa_read(x = convert_numbers(readLines("rwatest.txt")))
df
#> # A tibble: 26 × 6
#> time author text source emoji emoji_name
#> <dttm> <fct> <chr> <chr> <lis> <list>
#> 1 2021-05-30 18:44:57 <NA> پیامها و تماسها سرتاسر… text i… <NUL… <NULL>
#> 2 2021-05-30 18:44:57 Sattar-b سلام،خسته نباشید text i… <NUL… <NULL>
#> 3 2021-05-30 18:44:57 Sattar-b در مورد اطلاعیه شطرنجت… text i… <NUL… <NULL>
#> 4 2021-05-30 18:45:57 شطرنج سلام مچکرم text i… <NUL… <NULL>
#> 5 2021-05-30 18:45:57 شطرنج در خدمتم text i… <NUL… <NULL>
#> 6 2021-05-30 18:45:57 Sattar-b مسابقاته یا آموزش شطرن… text i… <NUL… <NULL>
#> 7 2021-05-30 18:46:57 شطرنج هم مسابقات داریم هم ام… text i… <NUL… <NULL>
#> 8 2021-05-30 18:46:57 شطرنج اموزش یه صورت عمومی و … text i… <NUL… <NULL>
#> 9 2021-05-30 18:47:57 شطرنج کلاس نیمه خصوصی از شنب… text i… <NUL… <NULL>
#> 10 2021-05-30 18:47:57 شطرنج میتونید شرکت کنید text i… <NUL… <NULL>
#> # … with 16 more rows
Created on 2022-02-05 by the reprex package <https://reprex.tidyverse.org>
(v2.0.1)
—
Reply to this email directly, view it on GitHub
<#28 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASR6KGAIV3OHHODVHJUNBGLUZV54NANCNFSM5NSFJKNQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>