How to Skip Columns of CSV file

╄→尐↘猪︶ㄣ 提交于 2019-12-24 11:14:03

问题


I am trying to upload data from certain fields in a CSV file to an already existing table.

From my understanding, the way to do this is to create a new table and then append the relevant columns of the newly created table to the corresponding columns of the main table.

How exactly do I append certain columns of data from one table to another? As in, what specific commands?

I am using the bigquery api and the python-client-library.


回答1:


You can use pandas library for that. import pandas as pd data = pd.read_csv('input_data.csv') useful_columns = [col1, col2, ... ] # List the columns you need data[useful_columns].to_csv('result_data.csv', index=False) # index=False is to prevent creating extra column



来源:https://stackoverflow.com/questions/46546388/how-to-skip-columns-of-csv-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!