[問題] 1G多大資料預處理
想請問各位版上的前輩
對比較大的純文字檔(約1.5G)預處理怎麼做比較好
我的做法是先讀ftp.log_20190103
邊處理邊把資料寫進新的檔案ftp.log_new中
程式碼如下
希望各位前輩給點明燈
感激不盡
file_write_obj = open("ftp.log_new", 'w')
with open("ftp.log_20190103",'r') as f:
for line in f:
try:
line_list = list(line)
line_list.insert(6,',')
line_list.insert(16,',')
line_list.insert(24,',')
nPos=line_list.index(']')
line_list.insert(nPos+2,',')
str_2="".join(line_list)
file_write_obj.writelines(str_2)
except :
pass
file_write_obj.close()
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 114.25.143.98 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1569046403.A.5CE.html
推
09/21 17:43,
5年前
, 1F
09/21 17:43, 1F
推
09/21 18:32,
5年前
, 2F
09/21 18:32, 2F
→
09/21 18:32,
5年前
, 3F
09/21 18:32, 3F
→
09/21 18:42,
5年前
, 4F
09/21 18:42, 4F
推
09/21 19:15,
5年前
, 5F
09/21 19:15, 5F
推
09/21 21:58,
5年前
, 6F
09/21 21:58, 6F
推
09/22 09:13,
5年前
, 7F
09/22 09:13, 7F
推
09/22 19:49,
5年前
, 8F
09/22 19:49, 8F
→
09/22 19:49,
5年前
, 9F
09/22 19:49, 9F
推
09/26 19:55,
5年前
, 10F
09/26 19:55, 10F
推
09/27 19:07,
5年前
, 11F
09/27 19:07, 11F
→
09/27 19:09,
5年前
, 12F
09/27 19:09, 12F
→
09/27 19:09,
5年前
, 13F
09/27 19:09, 13F
推
10/07 02:24,
5年前
, 14F
10/07 02:24, 14F