R ဖြင့် ရက်စွဲအလိုက် ဖိုင်များကို စာရင်းပြုစုနည်း (ဥပမာနှင့်အတူ)
ရက်စွဲအလိုက် လက်ရှိလုပ်ဆောင်နေသော R တွင် ဖိုင်များကို စာရင်းပြုစုရန် အောက်ပါအခြေခံ syntax ကို သင်အသုံးပြုနိုင်သည်-
#extract all CSV files in working directory file_info = file. info ( list.files (pattern=" *.csv ")) #sort files based on mtime (date and time modification) file_info = file_info[ with (file_info, order (as. POSIXct (mtime))), ] #view only file names with modification date and time file_info[c(" mtime ")]
အောက်ဖော်ပြပါ ဥပမာသည် ဤ syntax ကို လက်တွေ့တွင် မည်သို့အသုံးပြုရမည်ကို ပြသထားသည်။
ဥပမာ- R ဖြင့် ရက်စွဲအလိုက် ဖိုင်များကို စာရင်းပြုစုနည်း
ရက်စွဲအလိုက် လက်ရှိလုပ်ဆောင်နေတဲ့ R မှာ လက်ရှိအလုပ်လုပ်နေတဲ့ လမ်းညွှန် ထဲမှာ CSV ဖိုင်တွေအားလုံးကို စာရင်းပြုစုချင်တယ်ဆိုပါစို့။
ကျွန်ုပ်သည် လက်ရှိလုပ်ဆောင်နေသော လမ်းညွှန်မှ CSV ဖိုင်များ (ဖိုင်အချက်အလက်နှင့်အတူ) အားလုံးကို ပထမဆုံးထုတ်ယူရန် အောက်ပါ syntax ကို အသုံးပြုနိုင်ပါသည်။
#extract all CSV files in working directory file_info = file. info ( list.files (pattern=" *.csv ")) #view all CSV files file_info size isdir mode mtime ctime atime exe basketball_data.csv 55 FALSE 666 2023-01-06 11:07:43 2022-07-12 09:07:26 2023-04-18 09:42:19 no df1.csv 126 FALSE 666 2022-04-21 10:48:24 2022-04-21 10:48:24 2023-04-18 09:42:19 no df2.csv 126 FALSE 666 2022-04-21 10:48:30 2022-04-21 10:48:29 2023-04-18 09:42:19 no df3.csv 126 FALSE 666 2022-04-21 10:48:34 2022-04-21 10:48:34 2023-04-18 09:42:19 no my_data.csv 53 FALSE 666 2022-09-09 09:02:21 2022-04-22 09:00:13 2023-04-18 09:42:19 no my_list.csv 90 FALSE 666 2022-04-21 09:40:01 2022-04-21 09:39:59 2023-04-18 09:42:19 no my_test.csv 146 FALSE 666 2022-04-21 09:42:25 2022-04-21 09:42:25 2023-04-18 09:42:19 no player_stats.csv 137 FALSE 666 2023-04-11 09:07:20 2023-04-11 09:07:20 2023-04-18 09:42:19 no players_data.csv 50 FALSE 666 2023-01-06 09:44:12 2023-01-06 09:44:12 2023-04-18 09:42:19 no team_info.csv 131 FALSE 666 2023-04-11 09:07:21 2023-04-11 09:07:21 2023-04-18 09:42:19 no test.csv 18059168 FALSE 666 2022-09-07 09:07:34 2020-02-01 13:44:03 2023-04-18 09:42:19 no uneven_data.csv 43 FALSE 666 2023-01-06 14:02:17 2023-01-06 14:00:27 2023-04-18 09:42:19 no
ထို့နောက် ဖိုင်များကို mtime အလိုက် အမိန့်ပေးရန်အတွက် order() လုပ်ဆောင်ချက်ကို အသုံးပြုနိုင်ပြီး၊ ဖိုင်များကို နောက်ဆုံးမွမ်းမံထားသည့် နေ့စွဲနှင့် အချိန်ကို ကိုယ်စားပြုသည့်-
#sort files based on mtime (date and time modification) file_info = file_info[ with (file_info, order (as. POSIXct (mtime))), ] #view sorted files file_info size isdir mode mtime ctime atime exe my_list.csv 90 FALSE 666 2022-04-21 09:40:01 2022-04-21 09:39:59 2023-04-18 09:42:19 no my_test.csv 146 FALSE 666 2022-04-21 09:42:25 2022-04-21 09:42:25 2023-04-18 09:42:19 no df1.csv 126 FALSE 666 2022-04-21 10:48:24 2022-04-21 10:48:24 2023-04-18 09:42:19 no df2.csv 126 FALSE 666 2022-04-21 10:48:30 2022-04-21 10:48:29 2023-04-18 09:42:19 no df3.csv 126 FALSE 666 2022-04-21 10:48:34 2022-04-21 10:48:34 2023-04-18 09:42:19 no test.csv 18059168 FALSE 666 2022-09-07 09:07:34 2020-02-01 13:44:03 2023-04-18 09:42:19 no my_data.csv 53 FALSE 666 2022-09-09 09:02:21 2022-04-22 09:00:13 2023-04-18 09:42:19 no players_data.csv 50 FALSE 666 2023-01-06 09:44:12 2023-01-06 09:44:12 2023-04-18 09:42:19 no basketball_data.csv 55 FALSE 666 2023-01-06 11:07:43 2022-07-12 09:07:26 2023-04-18 09:42:19 no uneven_data.csv 43 FALSE 666 2023-01-06 14:02:17 2023-01-06 14:00:27 2023-04-18 09:42:19 no player_stats.csv 137 FALSE 666 2023-04-11 09:07:20 2023-04-11 09:07:20 2023-04-18 09:42:19 no team_info.csv 131 FALSE 666 2023-04-11 09:07:21 2023-04-11 09:07:21 2023-04-18 09:42:19 no
၎င်းအစား ဖန်တီးသည့်ရက်စွဲ ဖြင့် ဖိုင်များကို စီရန် သို့မဟုတ် အသုံးပြုခွင့်ရက်စွဲ ဖြင့် ဖိုင်များကို စီရန် အချိန်မီ လိုပါက ctime ကို အသုံးပြုနိုင်ကြောင်း သတိပြုပါ။
နောက်ဆုံးတွင်၊ ကျွန်ုပ်တို့သည် ဖိုင်အမည်များနှင့် ၎င်းတို့နောက်ဆုံးမွမ်းမံထားသော နေ့စွဲနှင့် အချိန်တို့ကိုသာ ပြသရန် ဒေတာဘောင်ကို ခွဲသတ်မှတ်နိုင်သည်-
#view only file names with modification date and time file_info[c(" mtime ")] mtime my_list.csv 2022-04-21 09:40:01 my_test.csv 2022-04-21 09:42:25 df1.csv 2022-04-21 10:48:24 df2.csv 2022-04-21 10:48:30 df3.csv 2022-04-21 10:48:34 test.csv 2022-09-07 09:07:34 my_data.csv 2022-09-09 09:02:21 players_data.csv 2023-01-06 09:44:12 basketball_data.csv 2023-01-06 11:07:43 uneven_data.csv 2023-01-06 14:02:17 player_stats.csv 2023-04-11 09:07:20 team_info.csv 2023-04-11 09:07:21
သင်အလိုရှိပါက ရက်စွဲအလိုက် ဖိုင်အမည်များကိုသာ ပြသနိုင်သည်-
#view only file names
rownames(file_info)
[1] "my_list.csv" "my_test.csv" "df1.csv" "df2.csv" "df3.csv"
[6] "test.csv" "my_data.csv" "players_data.csv" "basketball_data.csv" "uneven_data.csv"
[11] "player_stats.csv" "team_info.csv"
CSV ဖိုင်အမည် ၁၂ ခုကို ရက်စွဲဖြင့် မှာထားသည်။
ဆက်စပ်- R တွင် list.files() Function ကိုအသုံးပြုနည်း (ဥပမာ 4 ခု)
ထပ်လောင်းအရင်းအမြစ်များ
အောက်ဖော်ပြပါ သင်ခန်းစာများသည် R တွင် အခြားဘုံအလုပ်များကို မည်သို့လုပ်ဆောင်ရမည်ကို ရှင်းပြသည်-
R တွင် Zip ဖိုင်များကိုဖတ်နည်း
CSV ဖိုင်များကို R သို့မည်သို့တင်သွင်းရမည်နည်း။
Excel ဖိုင်များကို R သို့ဘယ်လိုတင်သွင်းမလဲ။