GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — LearnPython/ReadCSVFile.py at master · Pragad/LearnPython Expand file tree/ Copy pathReadCSVFile.pyMore file actions 42 lines (39 loc) · 1.13 KB / Copy pathReadCSVFile.pyFile metadata and controls42 lines (39 loc) · 1.13 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 #! /usr/bin/env/python import csv import time import pandas from collections import defaultdict orderBaseDict = {} orderIdDict = defaultdict(list) prodIdDict = {} deptIdDict = {} allDetailsList = [] filename = 'order_products__prior.csv' filename2 = 'departments.csv' csv_delimiter = ',' print(time.strftime("%Y-%m-%d %H:%M:%S")) count1 = 0 count2 = 0 with open(filename2) as csvfile: readCSV = csv.reader(csvfile, delimiter=',') #has_header = csv.Sniffer().has_header(csvfile.read(1024)) #if has_header: # next(readCSV) for row in readCSV: count1 += 1 #prodId = row[0] #prodName = row[1] #deptId = row[3] #prodIdDict[prodId] = (prodName, deptId) print(time.strftime("%Y-%m-%d %H:%M:%S")) print("Num rows: " + str(count1)) def open_with_pandas_read_csv(filename): df = pandas.read_csv(filename, sep=csv_delimiter) data = df.values prodList = [] print(df.loc[df['order_id'] == 2].values[0]) for row in df.loc[df['order_id'] == 2].values: prodList.append(row[1]) print(prodList) open_with_pandas_read_csv(filename) print(time.strftime("%Y-%m-%d %H:%M:%S")) |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |