Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have the following code: 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])

I have the following code:

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"])

Accordingly, this is the CSV file:

image text in transcribed

As you can tell, the Member Date's are all different. I am wanting to rewrite the dates to be in MM/DD/YYYY format. I need a regex code, if possible, to do this. I prefer no Pandas because I don't know what that is. This is for a beginner level coding class.

Name Credit Card Mamie Mason Visa Dr. Jorge Leonard Sue Robertson Gilbert Houston American Express American Express Mastercard Diners Club United States & Canada Discover Card Randy Griffith Lucile Bishop male Visa Mr. Shane Hughes Larry Sparks Mastercard Dr. Sadie Hogan Visa Vera Sharp Amanda Craig Discover Card American Express Mister Arthur Wallace Discover Card Gender SSN Member Date Phone State female 459-69-6647 Mon Aug 01 2016 12:06:01 GMT-0400 (Eastern Daylight Time) 9472284457 Indiana male 267-90-8144 10/17/2015 (482) 962-5537 Pennsylvania female 431-17-5882 Fri Jun 03 2016 01:34:30 GMT-0400 (Eastern Daylight Time) (387) 395-7066 Virginia male 469-80-8860 Wed May 02 2012 00:45:29 GMT-0400 (Eastern Daylight Time) 5776043558 Kentucky male 936-86-6880 2/4/2006 (310) 611-5796 Delaware female 443-08-6297 Tue May 31 2016 06:26:56 GMT-0400 (Eastern Daylight Time) (808) 609-2200 Utah 278-42-7591 2/17/2006 3356852122 Pennsylvania male 211-00-3913 28/9/2007 6667374920 IN female 425-51-1446 Mon Jul 02 2007 21:31:31 GMT-0400 (Eastern Daylight Time) 3189038083 Kansas female 337-52-6574 7/3/2015 8676596027 C.o. female 373-59-4142 Sun Aug 17 2014 08:44:20 GMT-0400 (Eastern Daylight Time) (951) 347-3265 Michigan male 120-54-7783 13/12/2008 (562) 988-4539 W.A. male 603-37-0899 3/28/2016 8308268822 M.T. female 549-30-5657 14/7/2007 3464159274 California female 432-20-2722 Wed Apr 08 2009 12:50:08 GMT-0400 (Eastern Daylight Time) (812) 887-7136 M.S. female 937-21-8751 Sat Aug 01 2015 13:47:43 GMT-0400 (Eastern Daylight Time) (986) 478-9204 OK male 332-30-7548 14/12/2007 (919) 727-4554 Nevada female 523-10-3166 6/3/2017 8164602604 1.A. male 337-02-8478 10/3/2013 (288) 821-6886 Wyoming male 429-61-7058 2/5/2016 4058751537 R.I. male 869-64-4308 6/3/2016 (225) 276-1062 G.A. male 557-47-8699 23/10/2011 4862697087 Delaware male 852-24-7710 3/30/2012 5156863740 Pennsylvania female 325-42-5441 Sun May 21 2006 15:15:45 GMT-0400 (Eastern Daylight Time) 6254005776 Vermont male 666-06-9299 Tue Jun 14 2011 11:14:04 GMT-0400 (Eastern Daylight Time) 7449056431 K.Y. Zip Email 82439-3619 m.masonason@gig.org 44795 1.leonardeonard@leiwauhi.gov 97198 s.robertsonobertson@odejo.co 59108-0390 g.houstonouston@fuzsi.co 22646-1080 r.griffithriffith@iptiipu.ca 57189-7317 bishopishop@fudkilso.com 67098-3590 s.hughesughes@leh.net 81455-5156 1.sparksparks@gafnecnuc.au 97873-1458 s.Hogan@wo.gov 73806 v.sharpharp@vulos.edu 65251 a.craigraig@lu.nz 89954 a.wallaceallace@wiclacpud.net 88094-1943 j.estradastrada@te.info 83688-4346 o.Lee@tudde.info 03831-4171 L.Fox@kak.ca 31468-4649 1.doyleoyle@ovo.gov 47519-6358 c.powersowers@wo.org 26609-9984 s. Moran@eziwgi.co 85533 rmendezendez@ijmag.ca 61790-5160 C.Mendoza@izofera.edu 92801 m.Jenkins@ni.au 69139 v.robertsoberts@utseodu.com 39347-8948 L.kinging@ro.com 27339 v.bishopishop@vi.org 69174-1109 f.foxox@pam.co Joe Estrada Diners Club United States & Canada Ophelia Lee Diners Club United States & Canada Mastercard Mastercard Miss Leona Fox Miss Lena Doyle Curtis Powers Susie Moran Discover Card Discover Card Mister Ray Mendez Visa Clyde Mendoza Discover Card Mister Mike Jenkins Visa Mr. Vincent Roberts Mastercard Visa Lucas King Victoria Bishop Doctor Francis Fox Mastercard Discover Card Name Credit Card Mamie Mason Visa Dr. Jorge Leonard Sue Robertson Gilbert Houston American Express American Express Mastercard Diners Club United States & Canada Discover Card Randy Griffith Lucile Bishop male Visa Mr. Shane Hughes Larry Sparks Mastercard Dr. Sadie Hogan Visa Vera Sharp Amanda Craig Discover Card American Express Mister Arthur Wallace Discover Card Gender SSN Member Date Phone State female 459-69-6647 Mon Aug 01 2016 12:06:01 GMT-0400 (Eastern Daylight Time) 9472284457 Indiana male 267-90-8144 10/17/2015 (482) 962-5537 Pennsylvania female 431-17-5882 Fri Jun 03 2016 01:34:30 GMT-0400 (Eastern Daylight Time) (387) 395-7066 Virginia male 469-80-8860 Wed May 02 2012 00:45:29 GMT-0400 (Eastern Daylight Time) 5776043558 Kentucky male 936-86-6880 2/4/2006 (310) 611-5796 Delaware female 443-08-6297 Tue May 31 2016 06:26:56 GMT-0400 (Eastern Daylight Time) (808) 609-2200 Utah 278-42-7591 2/17/2006 3356852122 Pennsylvania male 211-00-3913 28/9/2007 6667374920 IN female 425-51-1446 Mon Jul 02 2007 21:31:31 GMT-0400 (Eastern Daylight Time) 3189038083 Kansas female 337-52-6574 7/3/2015 8676596027 C.o. female 373-59-4142 Sun Aug 17 2014 08:44:20 GMT-0400 (Eastern Daylight Time) (951) 347-3265 Michigan male 120-54-7783 13/12/2008 (562) 988-4539 W.A. male 603-37-0899 3/28/2016 8308268822 M.T. female 549-30-5657 14/7/2007 3464159274 California female 432-20-2722 Wed Apr 08 2009 12:50:08 GMT-0400 (Eastern Daylight Time) (812) 887-7136 M.S. female 937-21-8751 Sat Aug 01 2015 13:47:43 GMT-0400 (Eastern Daylight Time) (986) 478-9204 OK male 332-30-7548 14/12/2007 (919) 727-4554 Nevada female 523-10-3166 6/3/2017 8164602604 1.A. male 337-02-8478 10/3/2013 (288) 821-6886 Wyoming male 429-61-7058 2/5/2016 4058751537 R.I. male 869-64-4308 6/3/2016 (225) 276-1062 G.A. male 557-47-8699 23/10/2011 4862697087 Delaware male 852-24-7710 3/30/2012 5156863740 Pennsylvania female 325-42-5441 Sun May 21 2006 15:15:45 GMT-0400 (Eastern Daylight Time) 6254005776 Vermont male 666-06-9299 Tue Jun 14 2011 11:14:04 GMT-0400 (Eastern Daylight Time) 7449056431 K.Y. Zip Email 82439-3619 m.masonason@gig.org 44795 1.leonardeonard@leiwauhi.gov 97198 s.robertsonobertson@odejo.co 59108-0390 g.houstonouston@fuzsi.co 22646-1080 r.griffithriffith@iptiipu.ca 57189-7317 bishopishop@fudkilso.com 67098-3590 s.hughesughes@leh.net 81455-5156 1.sparksparks@gafnecnuc.au 97873-1458 s.Hogan@wo.gov 73806 v.sharpharp@vulos.edu 65251 a.craigraig@lu.nz 89954 a.wallaceallace@wiclacpud.net 88094-1943 j.estradastrada@te.info 83688-4346 o.Lee@tudde.info 03831-4171 L.Fox@kak.ca 31468-4649 1.doyleoyle@ovo.gov 47519-6358 c.powersowers@wo.org 26609-9984 s. Moran@eziwgi.co 85533 rmendezendez@ijmag.ca 61790-5160 C.Mendoza@izofera.edu 92801 m.Jenkins@ni.au 69139 v.robertsoberts@utseodu.com 39347-8948 L.kinging@ro.com 27339 v.bishopishop@vi.org 69174-1109 f.foxox@pam.co Joe Estrada Diners Club United States & Canada Ophelia Lee Diners Club United States & Canada Mastercard Mastercard Miss Leona Fox Miss Lena Doyle Curtis Powers Susie Moran Discover Card Discover Card Mister Ray Mendez Visa Clyde Mendoza Discover Card Mister Mike Jenkins Visa Mr. Vincent Roberts Mastercard Visa Lucas King Victoria Bishop Doctor Francis Fox Mastercard Discover Card

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions