私はPythonスクリプトをスタックして、.txtファイルを開き、そのファイルから単語のリストを作成し、単語が何回出現(カウンタ) .csvファイル内。私のファイルの名前は1870.txt - 1892(1871,1872,1873.1.82.txt)です。そこからすべてが機能しますが、各ファイルを次の列に入れたいと思います。Pythonは新しい列を作成し、.CSVファイルにデータを格納します
def putInExcel(outputt):
i = 1790
while i < 1892:
inputt = str(i) + '.txt' #Making text file name
writefile = open(outputt)
writer = csv.writer(writefile)
with open(inputt) as file: #Separating each word and storing in list
text = file.read().lower()
text = re.sub('[^a-z\ \']+', " ", text)
words = list(text.split())
for word in words:
cnt[word] += 1
for key, count in cnt.iteritems(): #De-dent this block
writer.writerow([key,count]) #Output both the key and the count
writefile.close()
i = i+1
このスクリプトは動作していますが、すべてが1列に格納されています。 誰かに何か考えがありますか?ありがとうございました!
これは私が探しているものです!しかし、私は理解し、コードを私のものと接続しようとしています – Ukii
私は1751年のために何が意味するのか分かりません...。申し訳ありませんが、あるコードから別のコードに移動することは難しいです。 – Ukii
「ここに配置する必要があるものは何でも」を意味します。私はそれが何であったかを明確にしようとしていました。 –