Created
October 3, 2019 13:53
-
-
Save zodman/26b07313517d9a46c6e154e6c54a220c to your computer and use it in GitHub Desktop.
small script to fetch all canadian companies who issued LMIA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mport rows | |
from collections import OrderedDict | |
from rows import fields, Table | |
import tqdm | |
files = [ | |
("2017Q2-Q1","Descargas/2017Q2_Positive_Employer_EN.csv"), | |
("2017Q3","Descargas/2017Q3_Positive_Employer-EN.csv"), | |
("2017Q4","Descargas/2017Q4_Positive_Employer-EN.csv"), | |
("2018Q1","Descargas/2018Q1_Positive_Employer_EN.csv"), | |
("2018Q2","Descargas/2018Q2_Positive_Employer_EN.csv"), | |
("2018Q3","Descargas/2018Q3_Positive_Employer_en.csv"), | |
("2018Q4","Descargas/2018Q4_Positive_Employer_en.csv"), | |
] | |
outputs =[] | |
for ph, fi in tqdm.tqdm(files): | |
output = rows.import_from_csv(fi) | |
outputs.append((ph,output)) | |
set_fields = OrderedDict([ | |
('year', fields.TextField), | |
("location", fields.TextField), | |
("company", fields.TextField), | |
("address", fields.TextField), | |
("noc", fields.TextField), | |
("count", fields.TextField), | |
]) | |
out = Table(fields = set_fields) | |
for year,output in tqdm.tqdm(outputs): | |
location, company, address = None, None, None | |
for row in tqdm.tqdm(output): | |
location_field = row[0].strip() | |
company_field = row.field_1.strip() | |
address_field = row.field_2.strip() | |
noc_field = row.field_3.strip() | |
count_field = row.field_4.strip() | |
if location_field: | |
location = location_field | |
address = address_field | |
if company_field: | |
company = company_field | |
if noc_field.strip(): | |
out.append({ | |
'year':year, | |
'location':location, 'company': company, | |
'address':address, 'noc': noc_field, | |
'count':count_field | |
}) | |
#print(location, company, address_field, noc_field, count_field) | |
rows.export_to_csv(out, "out.csv") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment