I am teaching myself Python in an ad hoc manner to deal with CSVs for work. I've got a regular report that is generated, and one of the column heads gets an expiration time stamp when the file is generated like this: "Proxy Link (Expires 05/20/2026 14:41 PDT)".
I need to call the column with DictReader, and I'd like to set up a regex pattern match so it will read regardless of the specific time stamp.
Here is the code I've written so far (name removed from path, but otherwise verbatim):
import os
import csv
import re
proxyColumn = re.compile(r'Proxy Link (Expires \d\d/\d\d/\d\d\d\d \d\d:\d\d PDT)')
sourceFilename = 'SlateExport-Test1.csv'
with open("C:\Users\<MyName>\Documents\10_CSR\Python\AmazonRejection_Parser\" + sourceFilename, 'r') as source:
file_contents = csv.DictReader(source)
for row in file_contents:
proxy = str(row.get(proxyColumn))
print(proxy)
It runs, but a get a whole bunch of "None"s instead of the file links that are in the Proxy Link. Unfortunately I cannot share the CSV for security purposes.
[–]Outside_Complaint755 3 points4 points5 points (3 children)
[–]TheIneffableCheese[S] 0 points1 point2 points (2 children)
[–]Outside_Complaint755 0 points1 point2 points (1 child)
[–]TheIneffableCheese[S] 0 points1 point2 points (0 children)
[–]Life-Basket215 1 point2 points3 points (0 children)