Home > other > Snow fly naked 720 degrees, a pandas take a column data, error and replace Spaces and line breaks
Snow fly naked 720 degrees, a pandas take a column data, error and replace Spaces and line breaks
Time:09-18
The import codecs The import OS The import regex The import pandas
# pandas read before cleaning the text data of single quotes
# pandas processing data Def pandas_fomat (filepath) : Print (' began to clean the data============')
Read_table=pandas. Read_table (filepath, engine='python', sep='|', the header=None, error_bad_lines=False) Column 73 # processing of data, each line multiple Spaces in a row, and there is a line breaks Read_table=read_table [[73]] [[73]]. Apply (lambda x: fix_lines (x), axis=1) # is above the lambda and fog, request a great god help ,1,3,73 read_table [[0]]. To_csv (' AppendTxt. TXT 'mode=' a ', the header=True, the index=None)
Print ("============clean data finish ')
Def fix_lines (x) : # processing the data in the list, update to the SQL database Result=' X="'. Join (x.s plit ()) # x=x.r eplace (', ', ') Result=x.s trip () Return the result
# traversal folder Def walkFile (filespath) : For root, dirs, files in OS. Walk (filespath) :
# root said that the current is on a visit to the folder path # dirs said subdirectory under the folder name list # files representing the file folder list