In this image i had 4 columns with repeated column names. i needed only 2 columns one for item and one for amount with all the values in only 2 columns.Can anyone please help me out.Thanks in advance.
If you can read 2 columns here, read 4 columns at a time. Access by their index. Assuming it's a CSV file,
import csv
rows = []
with open('file.csv') as csvfile:
reader = csv.reader(csvfile, ...)
for row in reader:
item_amount1 = row[1:3]
item_amount2 = row[3:5]
rows.extend([item_amount1, item_amount2])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.