chin2017-20200313
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
[[seminar-personal/chin2017]]
|~目次|
|#contents|
&br;
*おさらい [#p71808b9]
-[[前回ゼミ>http://f-lab.mydns.jp/index.php?seminar-N-202...
-CSVファイルの有効性
--0:OK
--1:NG(全然だめ)
--2:限りなくOKに近いけど、一部ダメ
*除外処理(3万件CSVに手作業で) [#xfd8f5a4]
-CSVを読み込む
-先頭10行を表示
-例:&ref(s.JPG);
--0:OK
--1:NG(全然だめ)->項目名なし、項目名内容が数字のみ、先...
--2:一部ダメ(欠損データあり ⇒NaN値あり(判断は難しいので...
--ソースコード
# -*- coding: utf-8 -*-
from gensim.models import Word2Vec
import pandas as pd
import pandas.io.common
import numpy as np
import codecs
import random
import os
import getenc
import time
import re
import sys
import shutil
pd.set_option('display.max_rows',None)
pd.set_option('display.max_columns',None)#列は省略号では...
from progressbar import *
start = time.time()
print("CSV list reading...")
csv_list_files="prep2_csv_list.csv"
with codecs.open(csv_list_files, 'r','utf8') as f:
csv_list =f.readlines()
len_csv =29995#len(csv_list)
print('The number of csv list:',len_csv)
drop_list =[]
for n in range(0,20):
fname=csv_list[n].strip()#空白文字を除外
if (os.path.exists(fname)):#サイズ制限:and os.path.g...
moji_code=getenc.getEncode(fname)
if moji_code is not None :
with codecs.open(fname,'rb',moji_code) as f:
try:
df = pd.read_csv(f,delimiter =",",nr...
#data = pd.read_csv(fname,nrows =10)
print(n)
print(fname)
print(df)
key_input = int(input())
if(key_input == 0):#0:ok
drop_list.append([n,fname,key_inpu...
continue
else:
drop_list.append([n,fname,key_inpu...
dst = (fname).replace("./", "@")
dst = dst.replace("/", "--")
shutil.copy(fname, './tmp/'+dst)
except pandas.io.common.EmptyDataError:
drop_list.append([n,fname,1])
print("ERROR: {} is empty".format(fn...
except pandas.io.common.AbstractMethodEr...
print("ERROR: {} is AbstractMethodEr...
drop_list.append([n,fname,1])
except pandas.io.common.DtypeWarning:
print("ERROR: {} is DtypeWarning".fo...
drop_list.append([n,fname,1])
except pandas.io.common.ParserError:
print("ERROR: {} is ParserError".for...
drop_list.append([n,fname,1])
except pandas.io.common.ParserWarning:
print("ERROR: {} is ParserWarning".f...
drop_list.append([n,fname,1])
except Exception as e:
print("%s 's error is %s"%(format(fn...
drop_list.append([n,fname,1])
else:
drop_list.append([n,fname,1])
else:
drop_list.append([n,fname,1])
df = pd.DataFrame(drop_list,columns=['index','path','fla...
df.to_csv("drop_list_all.txt",index=False,encoding="utf-...
-\\10.200.11.9\home\N\chin\20190313\tmp
-15911個CSVを除外(全体29995個)->半分以上使えないCSVみたい
-一部:&ref(drop_list_all.txt);
-全部除外(1):&ref(drop_list.txt);
終了行:
[[seminar-personal/chin2017]]
|~目次|
|#contents|
&br;
*おさらい [#p71808b9]
-[[前回ゼミ>http://f-lab.mydns.jp/index.php?seminar-N-202...
-CSVファイルの有効性
--0:OK
--1:NG(全然だめ)
--2:限りなくOKに近いけど、一部ダメ
*除外処理(3万件CSVに手作業で) [#xfd8f5a4]
-CSVを読み込む
-先頭10行を表示
-例:&ref(s.JPG);
--0:OK
--1:NG(全然だめ)->項目名なし、項目名内容が数字のみ、先...
--2:一部ダメ(欠損データあり ⇒NaN値あり(判断は難しいので...
--ソースコード
# -*- coding: utf-8 -*-
from gensim.models import Word2Vec
import pandas as pd
import pandas.io.common
import numpy as np
import codecs
import random
import os
import getenc
import time
import re
import sys
import shutil
pd.set_option('display.max_rows',None)
pd.set_option('display.max_columns',None)#列は省略号では...
from progressbar import *
start = time.time()
print("CSV list reading...")
csv_list_files="prep2_csv_list.csv"
with codecs.open(csv_list_files, 'r','utf8') as f:
csv_list =f.readlines()
len_csv =29995#len(csv_list)
print('The number of csv list:',len_csv)
drop_list =[]
for n in range(0,20):
fname=csv_list[n].strip()#空白文字を除外
if (os.path.exists(fname)):#サイズ制限:and os.path.g...
moji_code=getenc.getEncode(fname)
if moji_code is not None :
with codecs.open(fname,'rb',moji_code) as f:
try:
df = pd.read_csv(f,delimiter =",",nr...
#data = pd.read_csv(fname,nrows =10)
print(n)
print(fname)
print(df)
key_input = int(input())
if(key_input == 0):#0:ok
drop_list.append([n,fname,key_inpu...
continue
else:
drop_list.append([n,fname,key_inpu...
dst = (fname).replace("./", "@")
dst = dst.replace("/", "--")
shutil.copy(fname, './tmp/'+dst)
except pandas.io.common.EmptyDataError:
drop_list.append([n,fname,1])
print("ERROR: {} is empty".format(fn...
except pandas.io.common.AbstractMethodEr...
print("ERROR: {} is AbstractMethodEr...
drop_list.append([n,fname,1])
except pandas.io.common.DtypeWarning:
print("ERROR: {} is DtypeWarning".fo...
drop_list.append([n,fname,1])
except pandas.io.common.ParserError:
print("ERROR: {} is ParserError".for...
drop_list.append([n,fname,1])
except pandas.io.common.ParserWarning:
print("ERROR: {} is ParserWarning".f...
drop_list.append([n,fname,1])
except Exception as e:
print("%s 's error is %s"%(format(fn...
drop_list.append([n,fname,1])
else:
drop_list.append([n,fname,1])
else:
drop_list.append([n,fname,1])
df = pd.DataFrame(drop_list,columns=['index','path','fla...
df.to_csv("drop_list_all.txt",index=False,encoding="utf-...
-\\10.200.11.9\home\N\chin\20190313\tmp
-15911個CSVを除外(全体29995個)->半分以上使えないCSVみたい
-一部:&ref(drop_list_all.txt);
-全部除外(1):&ref(drop_list.txt);
ページ名: