需求:原本的csv文件的欄目太多了,裁減成所需的欄目;
使用pandas進行操作非常快:這是Chatgpt說的關於pandas和SQL的區別:
In summary, SQL and Pandas have different strengths and use cases. SQL is best suited for working with large, structured datasets stored in a database, while Pandas is best suited for working with smaller datasets stored in memory or in a variety of file formats. Pandas provides a more flexible and intuitive data structure, along with a rich set of functions and methods for data analysis and manipulation.
pandas的特點是用來處理文件類型的數據;
使用drop就能夠刪除不要的列了
import pandas
df = pandas.read_csv("./RFIDRingIDBindingTableSample.txt")
print(df.head(5))
df = df.drop(columns=['Device'])
print(df.head(5))
df.to_csv('./RFIDRingIDBindingTable.txt', header=None, index=None, sep=' ', mode='a')