12345678910111213141516171819202122232425 |
- #coding:utf8
- import psycopg2
- import codecs
- conn = psycopg2.connect(dbname="BiddingKM_test_10000",user="postgres",password="postgres",host="192.168.2.101")
-
- cursor = conn.cursor()
- cursor.execute(" select distinct id from articles ")
- all_doc_id = cursor.fetchall()
- for doc_id in all_doc_id:
- cursor.execute(" select sentence_text from sentences where doc_id='"+str(doc_id[0])+"' order by sentence_index ")
- all_sentence = cursor.fetchall()
- with codecs.open("export_article/"+str(doc_id[0])+".txt","w",encoding="utf8") as f:
- for sentence in all_sentence:
- f.write(sentence[0])
- f.write("\n")
-
- f.flush()
- f.close()
-
-
|