As shown below:
# -*- coding: UTF-8 -*- import import tensorflow as tf import pandas as pd import csv import math """ 1.Must be acquiredCSVFolder(ID:copies) 2.come (or go) back(ID:分词后的copies) """ flags = flags.DEFINE_string("train_file_address","D:/NLPWORD/cut_word_test/","Add training data file") flags.DEFINE_string("result_file_address","D:/NLPWORD/cut_word_test/hzytest_result.csv","Generation of resultant data files") FLAGS = def cut_word(train_data): """ Iterate the data by rows and write the results by rows in a csv :return:Segmentation results list """ jieba.load_userdict("") with open(FLAGS.result_file_address, "w", encoding='utf8') as csvfile: writer = (csvfile) for row in train_data.index: datas = train_data.loc[row].values[1] if isinstance(datas,str) or not (datas): words = (datas) line = '' for word in words: line = line + + " " ([train_data.loc[row].values[0], line]) def main(_): data = pd.read_csv(FLAGS.train_file_address) cut_word(data) if __name__ == "__main__": (main)
Above this python processing csv in the null value method is all I share with you, I hope to give you a reference, and I hope you support me more.