Skip to content

Commit

Permalink
append the file type to the downloaded data
Browse files Browse the repository at this point in the history
  • Loading branch information
LFISHER7 committed Jun 4, 2024
1 parent d5eb6fe commit 8a97d5f
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions openprescribing/pipeline/management/commands/import_scmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,16 @@ def handle(self, *args, **kwargs):
with tempfile.NamedTemporaryFile(mode="w+") as f:
writer = csv.writer(f, delimiter=",")
for line in reader:
# add the file type
line.insert(0, url["file_type"])

# Convert year-month dates to year-month-day
if len(line[0]) == 7:
line[0] = line[0] + "-01"
elif len(line[0]) == 6:
line[0] = line[0][:4] + "-" + line[0][4:6] + "-01"
if len(line[1]) == 7:
line[1] = line[1] + "-01"
elif len(line[1]) == 6:
line[1] = line[1][:4] + "-" + line[1][4:6] + "-01"
else:
assert False, line[0]
assert False, line[1]
writer.writerow(line)
print("{} | Wrote: {}".format(month, f.name))

Expand Down

0 comments on commit 8a97d5f

Please sign in to comment.