Home > other >  Merge the CSV file times wrong coding format
Merge the CSV file times wrong coding format

Time:11-21

When using code merge multiple CSV files, code:
The import pandas as pd
The import OS

F: \ ZPSJ Folder_Path=r ' '
F: \ ZPSJSX SaveFile_Path=r ' '
SaveFile_Name=r 'ZPSJSX. CSV'

OS. The chdir (Folder_Path)


File_list=OS. Listdir ()



Df=pd read_csv (Folder_Path + '\ \' + file_list [0], encoding='ANSI')



Df. To_csv (SaveFile_Path + '\ \' + SaveFile_Name, encoding='ANSI', the index=False)



For I in range (1, len (file_list) :

Df=pd read_csv (Folder_Path + '\ \' + file_list [I])

Df. To_csv (SaveFile_Path + '\ \' + SaveFile_Name, encoding='ANSI', the index=False, the header=False, mode='a +')

Computer in the CSV file is saved as a notepad displayed when coding format for ANSI, but the code to run times wrong
UnicodeDecodeError: 'utf-8' codec can 't decode byte 0 xb8 in position 0: invalid start byte

CodePudding user response:

Feeling is your py file code out of the question, what development tools do you use?
  • Related