Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Python code: I need a python code to extract information from a file. I would like to find out if women spend more money or
Python code:
I need a python code to extract information from a file. I would like to find out if women spend more money or if men do.
Here is the code I have to start with:
import csv import re data = []
with open('customerData.csv') as csvfile: reader = csv.DictReader(csvfile) for row in reader: data.append(row) print(data[0]) print(data[1]["Name"]) print(data[2]["Spent Past 30 Days"])
The excel file looks like this but has 1001 rows:
column B is gender, column S is money spent in the last 12 months
Name | Gender | SSN | Member Date | Phone | State | Zip | Credit Card | Credit Card_Number | Credit Card Exp | Gender | Favorite Radio Station | Purchases Past 30 Days | Spent Past 30 Days | Purchases Past 6 Months | Spent Past 6 Months | Purchases Past 12 Months | Spent Past 12 Months | |
Mamie Mason | female | 459-69-6647 | Mon Aug 01 2016 12:06:01 GMT-0400 (Eastern Daylight Time) | 9472284457 | Indiana | 82439-3619 | m.masonason@gig.org | Visa | 4263xxxxxxxx1913 | 23-Sep | female | WMMZ | 4 | $2,149.81 | 7 | $5,188.75 | 9 | $10,756.50 |
Dr. Jorge Leonard | male | 267-90-8144 | 10/17/15 | (482) 962-5537 | Pennsylvania | 44795 | j.leonardeonard@leiwauhi.gov | American Express | 3430xxxxxxx6344 | 22-Jun | male | WLRS | 4 | $1,510.68 | 5 | $3,679.59 | 15 | $11,241.27 |
Sue Robertson | female | 431-17-5882 | Fri Jun 03 2016 01:34:30 GMT-0400 (Eastern Daylight Time) | (387) 395-7066 | Virginia | 97198 | s.robertsonobertson@odejo.co | American Express | 3446xxxxxxx4624 | 21-Sep | female | WING | 4 | $2,094.67 | 9 | $6,289.29 | 13 | $11,071.11 |
Gilbert Houston | male | 469-80-8860 | Wed May 02 2012 00:45:29 GMT-0400 (Eastern Daylight Time) | 5776043558 | Kentucky | 59108-0390 | g.houstonouston@fuzsi.co | Mastercard | 5149xxxxxxxx7215 | 26-Jul | male | WOGV | 0 | $0 | 5 | $3,167.44 | 6 | $6,928.30 |
Randy Griffith | male | 936-86-6880 | 2/4/06 | (310) 611-5796 | Delaware | 22646-1080 | r.griffithriffith@iptiipu.ca | Diners Club United States & Canada | 5430xxxxxxxx1269 | 22-Jan | male | WJMP | 4 | $2,080.74 | 8 | $5,466.40 | 10 | $11,707.57 |
Lucile Bishop | female | 443-08-6297 | Tue May 31 2016 06:26:56 GMT-0400 (Eastern Daylight Time) | (808) 609-2200 | Utah | 57189-7317 | l.bishopishop@fudkilso.com | Discover Card | 6011xxxxxxxx4095 | 25-Mar | female | KACJ | 1 | $869.04 | 5 | $4,535.56 | 6 | $7,605.86 |
Mr. Shane Hughes | male | 278-42-7591 | 2/17/06 | 3356852122 | Pennsylvania | 67098-3590 | s.hughesughes@leh.net | Visa | 4694xxxxxxxx8259 | 23-Jun | male | WJTV | 2 | $1,417.77 | 7 | $5,436.54 | 8 | $8,565.21 |
Larry Sparks | male | 211-00-3913 | 28/9/2007 | 6667374920 | IN | 81455-5156 | l.sparksparks@gafnecnuc.au | Mastercard | 5117xxxxxxxx7913 | 23-Feb | male | WBME | 4 | $1,397.93 | 5 | $4,579.31 | 8 | $8,570.74 |
Dr. Sadie Hogan | female | 425-51-1446 | Mon Jul 02 2007 21:31:31 GMT-0400 (Eastern Daylight Time) | 3189038083 | Kansas | 97873-1458 | s.Hogan@wo.gov | Visa | 4061xxxxxxxx0424 | 18-Jun | female | KDHH | 0 | $0 | 3 | $1,389.21 | 10 | $5,401.19 |
Vera Sharp | female | 337-52-6574 | 7/3/15 | 8676596027 | C.O. | 73806 | v.sharpharp@vulos.edu | Discover Card | 6011xxxxxxxx0859 | 19-Jul | female | KBMB | 3 | $1,632.69 | 4 | $3,717.08 | 9 | $9,822.12 |
Amanda Craig | female | 373-59-4142 | Sun Aug 17 2014 08:44:20 GMT-0400 (Eastern Daylight Time) | (951) 347-3265 | Michigan | 65251 | a.craigraig@lu.nz | American Express | 3404xxxxxxx6419 | 18-Mar | female | WTHN | 0 | $0 | 5 | $2,825.44 | 8 | $6,937.98 |
Mister Arthur Wallace | male | 120-54-7783 | 13/12/2008 | (562) 988-4539 | W.A. | 89954 | a.wallaceallace@wiclacpud.net | Discover Card | 6011xxxxxxxx8686 | 23-Jul | male | KHST | 4 | $1,789.27 | 5 | $4,499.82 | 13 | $11,695.34 |
Joe Estrada | male | 603-37-0899 | 3/28/16 | 8308268822 | M.T. | 88094-1943 | j.estradastrada@te.info | Diners Club United States & Canada | 5480xxxxxxxx5609 | 17-Nov | male | KLTX | 2 | $982.99 | 4 | $2,259.46 | 13 | $8,527.65 |
Ophelia Lee | female | 549-30-5657 | 14/7/2007 | 3464159274 | California | 83688-4346 | o.Lee@tudde.info | Diners Club United States & Canada | 5429xxxxxxxx5084 | 23-Jul | female | KFRX | 4 | $1,433.33 | 5 | $4,591.54 | 7 | $7,983.28 |
Miss Leona Fox | female | 432-20-2722 | Wed Apr 08 2009 12:50:08 GMT-0400 (Eastern Daylight Time) | (812) 887-7136 | M.S. | 03831-4171 | l.Fox@kak.ca | Mastercard | 5178xxxxxxxx6824 | 19-Apr | female | WILF | 2 | $1,015.19 | 3 | $2,633.51 | 13 | $8,123.34 |
Miss Lena Doyle | female | 937-21-8751 | Sat Aug 01 2015 13:47:43 GMT-0400 (Eastern Daylight Time) | (986) 478-9204 | OK | 31468-4649 | l.doyleoyle@ovo.gov | Mastercard | 5192xxxxxxxx0458 | 17-Feb | female | KAYZ | 4 | $2,708.89 | 5 | $4,747.38 | 8 | $8,393.32 |
Curtis Powers | male | 332-30-7548 | 14/12/2007 | (919) 727-4554 | Nevada | 47519-6358 | c.powersowers@wo.org | Discover Card | 6011xxxxxxxx3280 | 22-Oct | male | KFNN | 2 | $1,375.68 | 6 | $5,159.13 | 15 | $13,100.08 |
Susie Moran | female | 523-10-3166 | 6/3/17 | 8164602604 | I.A. | 26609-9984 | s.Moran@eziwgi.co | Discover Card | 6011xxxxxxxx3578 | 26-Mar | female | KPDE | 2 | $801.30 | 6 | $4,742.96 | 7 | $8,497.81 |
Mister Ray Mendez | male | 337-02-8478 | 10/3/13 | (288) 821-6886 | Wyoming | 85533 | r.mendezendez@ijmag.ca | Visa | 4439xxxxxxxx2922 | 21-Jan | male | KWXT | 5 | $2,583.67 | 7 | $6,200.29 | 15 | $12,706.71 |
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started